From 6c572457926915523d9e1e816064eec4e5eff99c Mon Sep 17 00:00:00 2001 From: verebecske Date: Tue, 27 Oct 2020 23:29:50 +0100 Subject: [PATCH] feat: check `no-duplicate-param` in `taskSpec` --- .../__snapshots__/regresion.test.js.snap | 80 +++++++++++++++++++ src/rules/no-duplicate-param.ts | 3 + 2 files changed, 83 insertions(+) diff --git a/regression-tests/__snapshots__/regresion.test.js.snap b/regression-tests/__snapshots__/regresion.test.js.snap index e435cd7..45c10b7 100644 --- a/regression-tests/__snapshots__/regresion.test.js.snap +++ b/regression-tests/__snapshots__/regresion.test.js.snap @@ -482,6 +482,22 @@ Array [ "path": "./regression-tests/duplicate-params.yaml", "rule": "no-missing-param", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 24, + "endLine": 51, + "range": Array [ + 851, + 854, + ], + "startColumn": 21, + "startLine": 51, + }, + "message": "Duplicate param 'foo'", + "path": "./regression-tests/duplicate-params.yaml", + "rule": "no-duplicate-param", + }, Object { "level": "error", "loc": Object { @@ -514,6 +530,22 @@ Array [ "path": "./regression-tests/duplicate-params.yaml", "rule": "no-missing-param", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 22, + "endLine": 63, + "range": Array [ + 1065, + 1068, + ], + "startColumn": 19, + "startLine": 63, + }, + "message": "Duplicate param 'foo'", + "path": "./regression-tests/duplicate-params.yaml", + "rule": "no-duplicate-param", + }, Object { "level": "warning", "loc": Object { @@ -882,6 +914,22 @@ Array [ "path": "./regression-tests/no-duplicate-param.yaml", "rule": "no-duplicate-param", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 22, + "endLine": 26, + "range": Array [ + 413, + 416, + ], + "startColumn": 19, + "startLine": 26, + }, + "message": "Duplicate param 'foo'", + "path": "./regression-tests/no-duplicate-param.yaml", + "rule": "no-duplicate-param", + }, Object { "level": "error", "loc": Object { @@ -3714,6 +3762,22 @@ Array [ "path": "./regression-tests/task-duplicate-params.yaml", "rule": "no-missing-param", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 24, + "endLine": 34, + "range": Array [ + 555, + 558, + ], + "startColumn": 21, + "startLine": 34, + }, + "message": "Duplicate param 'foo'", + "path": "./regression-tests/task-duplicate-params.yaml", + "rule": "no-duplicate-param", + }, Object { "level": "warning", "loc": Object { @@ -3778,6 +3842,22 @@ Array [ "path": "./regression-tests/task-duplicate-params.yaml", "rule": "prefer-beta", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 22, + "endLine": 46, + "range": Array [ + 766, + 769, + ], + "startColumn": 19, + "startLine": 46, + }, + "message": "Duplicate param 'foo'", + "path": "./regression-tests/task-duplicate-params.yaml", + "rule": "no-duplicate-param", + }, Object { "level": "warning", "loc": Object { diff --git a/src/rules/no-duplicate-param.ts b/src/rules/no-duplicate-param.ts index 0eaab4c..a75bece 100644 --- a/src/rules/no-duplicate-param.ts +++ b/src/rules/no-duplicate-param.ts @@ -32,6 +32,9 @@ export default (docs, tekton, report) => { for (const pipeline of Object.values(tekton.pipelines)) { for (const task of pipeline.spec.tasks) { checkParams(getParams('Task', task), report); + if (task.taskSpec) { + checkParams(getParams('Task', task.taskSpec), report); + } } } };