From 19b11aac2cda0ab633f8c919a0f27fac70ba3df7 Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Wed, 30 Oct 2024 19:25:17 +0100 Subject: [PATCH] Enable lint command Signed-off-by: Francesco Torchia --- .eslintignore | 7 +- .eslintrc.default.js | 225 +++++++++++++++++++++++++ .eslintrc.js | 393 +++++++++++++++++++++---------------------- package.json | 5 + yarn.lock | 27 ++- 5 files changed, 453 insertions(+), 204 deletions(-) create mode 100644 .eslintrc.default.js diff --git a/.eslintignore b/.eslintignore index 4674f5c0..16060eb0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,8 +11,5 @@ node_modules/ dist dist-pkg .DS_Store -dynamic-importer.js -ksconfig.json -nuxt.config.js -shell/utils/dynamic-importer.js -shell/assets/fonts +pkg/harvester/index.ts +pkg/harvester/store/* diff --git a/.eslintrc.default.js b/.eslintrc.default.js new file mode 100644 index 00000000..10b3b90d --- /dev/null +++ b/.eslintrc.default.js @@ -0,0 +1,225 @@ +module.exports = { + env: { + browser: true, + node: true + }, + globals: { + NodeJS: true, + Timer: true + }, + plugins: [ + 'jest', + '@typescript-eslint' + ], + extends: [ + 'standard', + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:vue/vue3-recommended', + ], + rules: { + 'semi-spacing': 'off', + 'space-in-parens': 'off', + 'array-bracket-spacing': 'warn', + 'arrow-parens': 'warn', + 'arrow-spacing': [ + 'warn', + { + before: true, + after: true + } + ], + 'block-spacing': [ + 'warn', + 'always' + ], + 'brace-style': [ + 'warn', + '1tbs' + ], + 'comma-dangle': [ + 'warn', + 'only-multiline' + ], + 'comma-spacing': 'warn', + indent: [ + 'warn', + 2 + ], + 'keyword-spacing': 'warn', + 'newline-per-chained-call': [ + 'warn', + { ignoreChainWithDepth: 4 } + ], + 'no-trailing-spaces': 'warn', + 'func-call-spacing': [ + 'warn', + 'never' + ], + 'wrap-iife': 'off', + 'lines-between-class-members': [ + 'warn', + 'always', + { exceptAfterSingleLine: true } + ], + 'multiline-ternary': [ + 'warn', + 'never' + ], + 'no-whitespace-before-property': 'warn', + 'object-curly-spacing': [ + 'warn', + 'always' + ], + 'object-property-newline': 'warn', + 'object-shorthand': 'warn', + 'padded-blocks': [ + 'warn', + 'never' + ], + 'quote-props': 'warn', + 'rest-spread-spacing': 'warn', + semi: [ + 'warn', + 'always' + ], + 'space-before-function-paren': [ + 'warn', + 'never' + ], + 'space-infix-ops': 'warn', + 'spaced-comment': 'warn', + 'switch-colon-spacing': 'warn', + 'template-curly-spacing': [ + 'warn', + 'always' + ], + 'yield-star-spacing': [ + 'warn', + 'both' + ], + 'key-spacing': [ + 'warn', + { + align: { + beforeColon: false, + afterColon: true, + on: 'value', + mode: 'strict' + }, + multiLine: { + beforeColon: false, + afterColon: true + } + } + ], + 'object-curly-newline': [ + 'warn', + { + ObjectExpression: { + multiline: true, + minProperties: 3 + }, + ObjectPattern: { + multiline: true, + minProperties: 4 + }, + ImportDeclaration: { + multiline: true, + minProperties: 5 + }, + ExportDeclaration: { + multiline: true, + minProperties: 3 + } + } + ], + 'padding-line-between-statements': [ + 'warn', + { + blankLine: 'always', + prev: '*', + next: 'return' + }, + { + blankLine: 'always', + prev: 'function', + next: 'function' + }, + { + blankLine: 'always', + prev: [ + 'const', + 'let', + 'var' + ], + next: '*' + }, + { + blankLine: 'any', + prev: [ + 'const', + 'let', + 'var' + ], + next: [ + 'const', + 'let', + 'var' + ] + } + ], + quotes: [ + 'warn', + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true + } + ], + 'space-unary-ops': [ + 'warn', + { + words: true, + nonwords: false + } + ], + 'vue/one-component-per-file': 'off', + 'vue/no-deprecated-slot-attribute': 'off', + 'vue/require-explicit-emits': 'error', + 'vue/v-on-event-hyphenation': 'off' + }, + overrides: [ + { + files: [ + '**/*.{js,ts,vue}' + ], + rules: { + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/ban-types': 'off' + } + }, + { + files: [ + '**/*.test.{js,ts}', + '**/__tests__/**/*.{js,ts}', + '**/__mocks__/**/*.{js,ts}' + ], + rules: { + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + 'jest/prefer-expect-assertions': 'off' + }, + extends: [ + 'plugin:jest/all' + ] + }, + { + files: [ + '**/*.{js,vue}' + ], + rules: { '@typescript-eslint/explicit-module-boundary-types': 'off' } + } + ] +}; diff --git a/.eslintrc.js b/.eslintrc.js index c026fa66..c1ebc932 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,247 +1,244 @@ module.exports = { - "root": true, - "env": { - "browser": true, - "node": true + root: true, + env: { + browser: true, + node: true }, - "globals": { - "NodeJS": true, - "Timer": true + globals: { + NodeJS: true, + Timer: true }, - "extends": [ - "standard", - "eslint:recommended", - "@nuxtjs/eslint-config-typescript", - "plugin:cypress/recommended" + extends: [ + '.eslintrc.default.js' ], - "rules": { - "dot-notation": "off", - "generator-star-spacing": "off", - "guard-for-in": "off", - "linebreak-style": "off", - "new-cap": "off", - "no-empty": "off", - "no-extra-boolean-cast": "off", - "no-new": "off", - "no-plusplus": "off", - "no-useless-escape": "off", - "nuxt/no-cjs-in-config": "off", - "semi-spacing": "off", - "space-in-parens": "off", - "strict": "off", - "unicorn/no-new-buffer": "off", - "vue/html-self-closing": "off", - "vue/multi-word-component-names": "off", - "vue/no-reserved-component-names": "off", - "vue/no-unused-components": "warn", - "vue/no-v-html": "error", - "wrap-iife": "off", - "array-bracket-spacing": "warn", - "arrow-parens": "warn", - "arrow-spacing": [ - "warn", + rules: { + 'dot-notation': 'off', + 'generator-star-spacing': 'off', + 'guard-for-in': 'off', + 'linebreak-style': 'off', + 'new-cap': 'off', + 'no-empty': 'off', + 'no-extra-boolean-cast': 'off', + 'no-new': 'off', + 'no-plusplus': 'off', + 'no-useless-escape': 'off', + 'nuxt/no-cjs-in-config': 'off', + 'semi-spacing': 'off', + 'space-in-parens': 'off', + strict: 'off', + 'unicorn/no-new-buffer': 'off', + 'vue/html-self-closing': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/no-reserved-component-names': 'off', + 'vue/no-deprecated-v-on-native-modifier': 'off', + 'vue/no-useless-template-attributes': 'off', + 'vue/no-unused-components': 'warn', + 'vue/no-v-html': 'error', + 'wrap-iife': 'off', + 'array-bracket-spacing': 'warn', + 'arrow-parens': 'warn', + 'arrow-spacing': [ + 'warn', { - "before": true, - "after": true + before: true, + after: true } ], - "block-spacing": [ - "warn", - "always" + 'block-spacing': [ + 'warn', + 'always' ], - "brace-style": [ - "warn", - "1tbs" + 'brace-style': [ + 'warn', + '1tbs' ], - "comma-dangle": [ - "warn", - "only-multiline" + 'comma-dangle': [ + 'warn', + 'only-multiline' ], - "comma-spacing": "warn", - "curly": "warn", - "eqeqeq": "warn", - "func-call-spacing": [ - "warn", - "never" + 'comma-spacing': 'warn', + curly: 'warn', + eqeqeq: 'warn', + 'func-call-spacing': [ + 'warn', + 'never' ], - "implicit-arrow-linebreak": "warn", - "indent": [ - "warn", + 'implicit-arrow-linebreak': 'warn', + indent: [ + 'warn', 2 ], - "keyword-spacing": "warn", - "lines-between-class-members": [ - "warn", - "always", + 'keyword-spacing': 'warn', + 'lines-between-class-members': [ + 'warn', + 'always', + { exceptAfterSingleLine: true } + ], + 'multiline-ternary': [ + 'warn', + 'never' + ], + 'newline-per-chained-call': [ + 'warn', + { ignoreChainWithDepth: 4 } + ], + 'no-caller': 'warn', + 'no-cond-assign': [ + 'warn', + 'except-parens' + ], + 'no-console': 'warn', + 'no-debugger': 'warn', + 'no-eq-null': 'warn', + 'no-eval': 'warn', + 'no-trailing-spaces': 'warn', + 'no-undef': 'warn', + 'no-unused-vars': 'warn', + 'no-whitespace-before-property': 'warn', + 'object-curly-spacing': [ + 'warn', + 'always' + ], + 'object-property-newline': 'warn', + 'object-shorthand': 'warn', + 'padded-blocks': [ + 'warn', + 'never' + ], + 'prefer-arrow-callback': 'warn', + 'prefer-template': 'warn', + 'quote-props': 'warn', + 'rest-spread-spacing': 'warn', + semi: [ + 'warn', + 'always' + ], + 'space-before-function-paren': [ + 'warn', + 'never' + ], + 'space-infix-ops': 'warn', + 'spaced-comment': 'warn', + 'switch-colon-spacing': 'warn', + 'template-curly-spacing': [ + 'warn', + 'always' + ], + 'yield-star-spacing': [ + 'warn', + 'both' + ], + 'key-spacing': [ + 'warn', { - "exceptAfterSingleLine": true - } - ], - "multiline-ternary": [ - "warn", - "never" - ], - "newline-per-chained-call": [ - "warn", - { - "ignoreChainWithDepth": 4 - } - ], - "no-caller": "warn", - "no-cond-assign": [ - "warn", - "except-parens" - ], - "no-console": "warn", - "no-debugger": "warn", - "no-eq-null": "warn", - "no-eval": "warn", - "no-trailing-spaces": "warn", - "no-undef": "warn", - "no-unused-vars": "warn", - "no-whitespace-before-property": "warn", - "object-curly-spacing": [ - "warn", - "always" - ], - "object-property-newline": "warn", - "object-shorthand": "warn", - "padded-blocks": [ - "warn", - "never" - ], - "prefer-arrow-callback": "warn", - "prefer-template": "warn", - "quote-props": "warn", - "rest-spread-spacing": "warn", - "semi": [ - "warn", - "always" - ], - "space-before-function-paren": [ - "warn", - "never" - ], - "space-infix-ops": "warn", - "spaced-comment": "warn", - "switch-colon-spacing": "warn", - "template-curly-spacing": [ - "warn", - "always" - ], - "yield-star-spacing": [ - "warn", - "both" - ], - "key-spacing": [ - "warn", - { - "align": { - "beforeColon": false, - "afterColon": true, - "on": "value", - "mode": "minimum" + align: { + beforeColon: false, + afterColon: true, + on: 'value', + mode: 'minimum' }, - "multiLine": { - "beforeColon": false, - "afterColon": true + multiLine: { + beforeColon: false, + afterColon: true } } ], - "object-curly-newline": [ - "warn", + 'object-curly-newline': [ + 'warn', { - "ObjectExpression": { - "multiline": true, - "minProperties": 3 + ObjectExpression: { + multiline: true, + minProperties: 3 }, - "ObjectPattern": { - "multiline": true, - "minProperties": 4 + ObjectPattern: { + multiline: true, + minProperties: 4 }, - "ImportDeclaration": { - "multiline": true, - "minProperties": 5 + ImportDeclaration: { + multiline: true, + minProperties: 5 }, - "ExportDeclaration": { - "multiline": true, - "minProperties": 3 + ExportDeclaration: { + multiline: true, + minProperties: 3 } } ], - "padding-line-between-statements": [ - "warn", + 'padding-line-between-statements': [ + 'warn', { - "blankLine": "always", - "prev": "*", - "next": "return" + blankLine: 'always', + prev: '*', + next: 'return' }, { - "blankLine": "always", - "prev": "function", - "next": "function" + blankLine: 'always', + prev: 'function', + next: 'function' }, { - "blankLine": "always", - "prev": [ - "const", - "let", - "var" + blankLine: 'always', + prev: [ + 'const', + 'let', + 'var' ], - "next": "*" + next: '*' }, { - "blankLine": "any", - "prev": [ - "const", - "let", - "var" + blankLine: 'any', + prev: [ + 'const', + 'let', + 'var' ], - "next": [ - "const", - "let", - "var" + next: [ + 'const', + 'let', + 'var' ] } ], - "quotes": [ - "warn", - "single", + quotes: [ + 'warn', + 'single', { - "avoidEscape": true, - "allowTemplateLiterals": true + avoidEscape: true, + allowTemplateLiterals: true } ], - "space-unary-ops": [ - "warn", + 'space-unary-ops': [ + 'warn', { - "words": true, - "nonwords": false + words: true, + nonwords: false } ], - "vue/order-in-components": "off", - "vue/no-lone-template": "off", - "vue/v-slot-style": "off", - "vue/component-tags-order": "off", - "vue/no-mutating-props": "off", - "@typescript-eslint/no-unused-vars": "off", - "array-callback-return": "off", - "vue/one-component-per-file": "off", - "vue/no-deprecated-slot-attribute": "off", - "vue/require-explicit-emits": "off", - "vue/v-on-event-hyphenation": "off" + 'vue/order-in-components': 'off', + 'vue/no-lone-template': 'off', + 'vue/v-slot-style': 'off', + 'vue/component-tags-order': 'off', + 'vue/no-mutating-props': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-this-alias': 'off', + 'array-callback-return': 'off', + 'vue/one-component-per-file': 'off', + 'vue/no-deprecated-slot-attribute': 'off', + 'vue/require-explicit-emits': 'off', + 'vue/v-on-event-hyphenation': 'off' }, - "overrides": [ + overrides: [ { - "files": [ - "*.js" + files: [ + '*.js' ], - "rules": { - "prefer-regex-literals": "off", - "vue/component-definition-name-casing": "off", - "no-unreachable-loop": "off", - "computed-property-spacing": "off" + rules: { + 'prefer-regex-literals': 'off', + 'vue/component-definition-name-casing': 'off', + 'no-unreachable-loop': 'off', + 'computed-property-spacing': 'off' } } ] -} \ No newline at end of file +}; diff --git a/package.json b/package.json index e0ecc499..0c282d4d 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,14 @@ "dev": "NODE_ENV=dev ./node_modules/.bin/vue-cli-service serve", "build": "./node_modules/.bin/vue-cli-service build", "clean": "./node_modules/@rancher/shell/scripts/clean", + "lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .js,.ts,.vue .", "build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh", "serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs", "publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish", "parse-tag-name": "./node_modules/@rancher/shell/scripts/extension/parse-tag-name" + }, + "devDependencies": { + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^7.1.0" } } diff --git a/yarn.lock b/yarn.lock index 874c8f78..bc572391 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7481,6 +7481,14 @@ eslint-plugin-cypress@2.12.1: dependencies: globals "^11.12.0" +eslint-plugin-es@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz#75a7cdfdccddc0589934aeeb384175f221c57893" + integrity sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ== + dependencies: + eslint-utils "^2.0.0" + regexpp "^3.0.0" + eslint-plugin-es@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz#f0822f0c18a535a97c3e714e89f88586a7641ec9" @@ -7531,6 +7539,23 @@ eslint-plugin-n@15.2.0: resolve "^1.10.1" semver "^6.3.0" +eslint-plugin-node@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d" + integrity sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g== + dependencies: + eslint-plugin-es "^3.0.0" + eslint-utils "^2.0.0" + ignore "^5.1.1" + minimatch "^3.0.4" + resolve "^1.10.1" + semver "^6.1.0" + +eslint-plugin-promise@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz#06b3ad6d36b3c3ef3ec201c8a8d97049cf5dbb20" + integrity sha512-8trNmPxdAy3W620WKDpaS65NlM5yAumod6XeC4LOb+jxlkG4IVcp68c6dXY2ev+uT4U1PtG57YDV6EGAXN0GbQ== + eslint-plugin-vue@9.10.0: version "9.10.0" resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-9.10.0.tgz#bb6423166e6eab800344245b6eef6ce9480c78a7" @@ -12401,7 +12426,7 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow== -"semver@2 || 3 || 4 || 5", semver@7.5.4, semver@^5.5.0, semver@^5.7.1, semver@^6.0.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.6, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~7.0.0: +"semver@2 || 3 || 4 || 5", semver@7.5.4, semver@^5.5.0, semver@^5.7.1, semver@^6.0.0, semver@^6.1.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.6, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~7.0.0: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==