From 89113804db5f7c1d157b2342caded0b8f232fdf6 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Thu, 27 Mar 2025 16:29:10 +0100 Subject: [PATCH 1/2] feat: Add ESLint configuration and tool definitions for linting TypeScript and JavaScript --- eslint.config.mjs | 110 +++++++++++++++++++++++++++++ tools/definitions/eslint/tool.yaml | 51 +++++++++++++ tools/definitions/trivy/tool.yaml | 25 +++++++ 3 files changed, 186 insertions(+) create mode 100644 eslint.config.mjs create mode 100644 tools/definitions/eslint/tool.yaml create mode 100644 tools/definitions/trivy/tool.yaml diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..3432d6b2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,110 @@ +import emberPlugin from 'eslint-plugin-ember'; +import regexpPlugin from 'eslint-plugin-regexp'; + +export default [ + { + plugins: { + ember: emberPlugin, + regexp: regexpPlugin + }, + rules: { + // Ember rules + "ember/no-volatile-computed-properties": "error", + "ember/no-assignment-of-untracked-properties-used-in-tracking-contexts": "error", + "ember/no-restricted-resolver-tests": "error", + "ember/no-component-lifecycle-hooks": "error", + "ember/no-incorrect-calls-with-inline-anonymous-functions": "error", + "ember/new-module-imports": "error", + "ember/no-invalid-test-waiters": "error", + "ember/routes-segments-snake-case": "error", + "ember/no-settled-after-test-helper": "error", + "ember/no-test-support-import": "error", + "ember/closure-actions": "error", + "ember/no-string-prototype-extensions": "error", + "ember/no-deeply-nested-dependent-keys-with-each": "error", + "ember/no-empty-glimmer-component-classes": "error", + "ember/no-mixins": "error", + "ember/no-try-invoke": "error", + "ember/no-observers": "error", + "ember/use-ember-data-rfc-395-imports": "error", + "ember/no-on-calls-in-components": "error", + "ember/no-new-mixins": "error", + "ember/jquery-ember-run": "error", + "ember/avoid-using-needs-in-controllers": "error", + "ember/no-function-prototype-extensions": "error", + "ember/no-attrs-in-components": "error", + "ember/no-classic-classes": "error", + "ember/classic-decorator-hooks": "error", + "ember/require-valid-css-selector-in-test-helpers": "error", + "ember/classic-decorator-no-classic-methods": "error", + "ember/no-test-and-then": "error", + "ember/no-actions-hash": "error", + "ember/no-ember-super-in-es-classes": "error", + "ember/no-duplicate-dependent-keys": "error", + "ember/require-return-from-computed": "error", + "ember/no-ember-testing-in-module-scope": "error", + "ember/no-test-this-render": "error", + "ember/avoid-leaking-state-in-ember-objects": "error", + "ember/no-test-import-export": "error", + + // Regexp rules + "regexp/no-dupe-disjunctions": "error", + "regexp/no-useless-assertions": "error", + "regexp/no-useless-lazy": "error", + "regexp/no-non-standard-flag": "error", + "regexp/no-escape-backspace": "error", + "regexp/strict": "error", + "regexp/no-optional-assertion": "error", + "regexp/prefer-star-quantifier": "error", + "regexp/no-empty-alternative": "error", + "regexp/confusing-quantifier": "error", + "regexp/no-useless-two-nums-quantifier": "error", + "regexp/no-useless-set-operand": "error", + "regexp/no-super-linear-backtracking": "error", + "regexp/no-useless-range": "error", + "regexp/no-useless-flag": "error", + "regexp/no-useless-dollar-replacements": "error", + "regexp/no-useless-non-capturing-group": "error", + "regexp/prefer-set-operation": "error", + "regexp/no-dupe-characters-character-class": "error", + "regexp/no-obscure-range": "error", + "regexp/prefer-d": "error", + "regexp/no-invisible-character": "error", + "regexp/no-missing-g-flag": "error", + "regexp/no-useless-escape": "error", + "regexp/no-invalid-regexp": "error", + "regexp/prefer-predefined-assertion": "error", + "regexp/no-empty-string-literal": "error", + "regexp/no-empty-character-class": "error", + "regexp/no-empty-lookarounds-assertion": "error", + "regexp/no-useless-backreference": "error", + "regexp/no-empty-group": "error", + "regexp/negation": "error", + "regexp/optimal-lookaround-quantifier": "error", + "regexp/prefer-plus-quantifier": "error", + "regexp/prefer-question-quantifier": "error", + "regexp/no-trivially-nested-quantifier": "error", + "regexp/no-trivially-nested-assertion": "error", + "regexp/no-useless-quantifier": "error", + "regexp/prefer-range": "error", + "regexp/no-zero-quantifier": "error", + "regexp/prefer-character-class": "error", + "regexp/no-legacy-features": "error", + "regexp/sort-flags": "error", + "regexp/control-character-escape": "error", + "regexp/match-any": "error", + "regexp/no-potentially-useless-backreference": "error", + "regexp/no-useless-string-literal": "error", + "regexp/no-useless-character-class": "error", + "regexp/no-empty-capturing-group": "error", + "regexp/optimal-quantifier-concatenation": "error", + "regexp/no-misleading-unicode-character": "error", + "regexp/no-contradiction-with-assertion": "error", + "regexp/no-misleading-capturing-group": "error", + "regexp/no-lazy-ends": "error", + "regexp/simplify-set-operations": "error", + "regexp/prefer-unicode-codepoint-escapes": "error", + "regexp/use-ignore-case": "error" + } + } +]; \ No newline at end of file diff --git a/tools/definitions/eslint/tool.yaml b/tools/definitions/eslint/tool.yaml new file mode 100644 index 00000000..c1155171 --- /dev/null +++ b/tools/definitions/eslint/tool.yaml @@ -0,0 +1,51 @@ +version: 0.1 +tools: + definitions: + - name: eslint + runtime: node + package: eslint + shims: [eslint] + known_good_version: 8.10.0 +lint: + definitions: + - name: eslint + files: [typescript, javascript] + tools: [eslint] + description: Find and fix problems in your TS/JS code + commands: + - name: lint + version: ">=9.0.0" + direct_configs: + - eslint.config.js + - eslint.config.mjs + - eslint.config.cjs + output: eslint + run: eslint --output-file ${tmpfile} --format json ${target} + error_codes: [2] + read_output_from: tmp_file + batch: true + - name: lint + version: <=8.57.0 + direct_configs: + - .eslintrc + - .eslintrc.cjs + - .eslintrc.js + - .eslintrc.json + - .eslintrc.mjs + - .eslintrc.yaml + - .eslintrc.yml + output: eslint + run: eslint --output-file ${tmpfile} --format json ${target} + error_codes: [2] + read_output_from: tmp_file + batch: true + suggest_if: config_present + affects_cache: + - .eslintignore + - package.json + - tsconfig.json + issue_url_format: https://eslint.org/docs/rules/{} + known_good_version: 8.10.0 + version_command: + parse_regex: ${semver} + run: eslint --version diff --git a/tools/definitions/trivy/tool.yaml b/tools/definitions/trivy/tool.yaml new file mode 100644 index 00000000..c44816f1 --- /dev/null +++ b/tools/definitions/trivy/tool.yaml @@ -0,0 +1,25 @@ +version: 0.1 +downloads: + - name: trivy + downloads: + - url: https://github.com/aquasecurity/trivy/releases/download/v${version}/trivy_${version}_Linux-${cpu}.tar.gz + os: linux + cpu: + x86_64: 64bit + arm_64: ARM64 + - url: https://github.com/aquasecurity/trivy/releases/download/v${version}/trivy_${version}_macOS-${cpu}.tar.gz + os: macos + cpu: + x86_64: 64bit + arm_64: ARM64 + - url: https://github.com/aquasecurity/trivy/releases/download/v${version}/trivy_${version}_windows-${cpu}.zip + os: windows + cpu: + x86_64: 64bit + arm_64: ARM64 +tools: + definitions: + - name: trivy + download: trivy + shims: [trivy] + known_good_version: 0.44.1 \ No newline at end of file From 5fdb8fd73068ebcd5d6b5140c343194a7ff40471 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Thu, 27 Mar 2025 16:29:25 +0100 Subject: [PATCH 2/2] feat: Add definitions for Node.js, ESLint, and Trivy tools with runtime configurations --- definitions/runtimes/plugin.yaml | 66 +++++++++++++++++++ .../tools}/eslint/tool.yaml | 0 .../tools}/trivy/tool.yaml | 0 3 files changed, 66 insertions(+) create mode 100644 definitions/runtimes/plugin.yaml rename {tools/definitions => definitions/tools}/eslint/tool.yaml (100%) rename {tools/definitions => definitions/tools}/trivy/tool.yaml (100%) diff --git a/definitions/runtimes/plugin.yaml b/definitions/runtimes/plugin.yaml new file mode 100644 index 00000000..6457ca6f --- /dev/null +++ b/definitions/runtimes/plugin.yaml @@ -0,0 +1,66 @@ +version: 0.1 +downloads: + - name: node + downloads: + # macos arm64 was introduced after this version. + - os: macos + url: https://nodejs.org/dist/v${version}/node-v${version}-darwin-x64.tar.gz + version: <16.0.0 + strip_components: 1 + - os: + linux: linux + macos: darwin + cpu: + x86_64: x64 + arm_64: arm64 + url: https://nodejs.org/dist/v${version}/node-v${version}-${os}-${cpu}.tar.gz + strip_components: 1 + - os: windows + cpu: x86_64 + url: https://nodejs.org/dist/v${version}/node-v${version}-win-x64.zip + strip_components: 1 + +runtimes: + definitions: + - type: node + download: node + runtime_environment: + - name: HOME + value: ${env.HOME:-} + - name: PATH + list: + - "${runtime}/bin" + - "${runtime}" # Windows places binaries here instead of bin/ + - "${env.PATH}" + - name: http_proxy + value: ${env.http_proxy} + optional: true + - name: https_proxy + value: ${env.https_proxy} + optional: true + - name: NODE_EXTRA_CA_CERTS + value: ${env.NODE_EXTRA_CA_CERTS} + optional: true + - name: NODE_OPTIONS + value: ${env.NODE_OPTIONS} + optional: true + - name: NPM_CONFIG_USERCONFIG + value: ${env.NPM_CONFIG_USERCONFIG} + optional: true + # Necessary for some Windows install scripts + - name: COMSPEC + value: ${env.COMSPEC} + optional: true + linter_environment: + - name: PATH + list: ["${linter}/node_modules/.bin"] + - name: NODE_PATH + value: ${linter}/node_modules + - name: NODE_OPTIONS + value: ${env.NODE_OPTIONS} + optional: true + known_good_version: 18.20.5 + version_commands: + - run: node --version + parse_regex: ${semver} + shims: [node, npm, npx, corepack] diff --git a/tools/definitions/eslint/tool.yaml b/definitions/tools/eslint/tool.yaml similarity index 100% rename from tools/definitions/eslint/tool.yaml rename to definitions/tools/eslint/tool.yaml diff --git a/tools/definitions/trivy/tool.yaml b/definitions/tools/trivy/tool.yaml similarity index 100% rename from tools/definitions/trivy/tool.yaml rename to definitions/tools/trivy/tool.yaml