From 81a1f4244add157333aa160c443b4315b7908ca6 Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Mon, 28 Mar 2022 18:39:16 +0800 Subject: [PATCH] Add .eslintrc config to each packages Update packages .eslintrc.js Update components & admin-e2e-tests lint command --- packages/js/.eslintrc.js | 73 ------------------- packages/js/admin-e2e-tests/.eslintrc.js | 4 + packages/js/components/.eslintrc.js | 19 +++++ packages/js/components/package.json | 2 +- packages/js/csv-export/.eslintrc.js | 4 + packages/js/currency/.eslintrc.js | 4 + .../js/customer-effort-score/.eslintrc.js | 4 + packages/js/data/.eslintrc.js | 4 + packages/js/date/.eslintrc.js | 4 + .../.eslintrc.js | 4 + .../package.json | 2 + packages/js/eslint-plugin/.eslintrc.js | 4 + packages/js/eslint-plugin/package.json | 5 +- packages/js/experimental/.eslintrc.js | 4 + packages/js/explat/.eslintrc.js | 4 + packages/js/js-tests/.eslintrc.js | 4 + packages/js/navigation/.eslintrc.js | 4 + packages/js/notices/.eslintrc.js | 4 + packages/js/number/.eslintrc.js | 4 + packages/js/onboarding/.eslintrc.js | 4 + packages/js/style-build/.eslintrc.js | 4 + packages/js/tracks/.eslintrc.js | 4 + 22 files changed, 94 insertions(+), 75 deletions(-) delete mode 100644 packages/js/.eslintrc.js create mode 100644 packages/js/admin-e2e-tests/.eslintrc.js create mode 100644 packages/js/components/.eslintrc.js create mode 100644 packages/js/csv-export/.eslintrc.js create mode 100644 packages/js/currency/.eslintrc.js create mode 100644 packages/js/customer-effort-score/.eslintrc.js create mode 100644 packages/js/data/.eslintrc.js create mode 100644 packages/js/date/.eslintrc.js create mode 100644 packages/js/dependency-extraction-webpack-plugin/.eslintrc.js create mode 100644 packages/js/eslint-plugin/.eslintrc.js create mode 100644 packages/js/experimental/.eslintrc.js create mode 100644 packages/js/explat/.eslintrc.js create mode 100644 packages/js/js-tests/.eslintrc.js create mode 100644 packages/js/navigation/.eslintrc.js create mode 100644 packages/js/notices/.eslintrc.js create mode 100644 packages/js/number/.eslintrc.js create mode 100644 packages/js/onboarding/.eslintrc.js create mode 100644 packages/js/style-build/.eslintrc.js create mode 100644 packages/js/tracks/.eslintrc.js diff --git a/packages/js/.eslintrc.js b/packages/js/.eslintrc.js deleted file mode 100644 index a1a88c11ee0..00000000000 --- a/packages/js/.eslintrc.js +++ /dev/null @@ -1,73 +0,0 @@ -module.exports = { - env: { - 'jest/globals': true, - }, - extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], - settings: { - 'import/resolver': 'typescript', - // List of modules that are externals in our webpack config. - 'import/core-modules': [ '@woocommerce/settings', 'lodash', 'react' ], - react: { - pragma: 'createElement', - }, - }, - rules: { - // temporary conversion to warnings until the below are all handled. - '@wordpress/i18n-translator-comments': 'warn', - '@wordpress/valid-sprintf': 'warn', - 'jsdoc/check-tag-names': [ - 'error', - { - definedTags: [ - 'jest-environment', - 'filter', - 'action', - 'slotFill', - 'scope', - ], - }, - ], - 'jsdoc/tag-lines': 'off', - 'jest/no-deprecated-functions': 'warn', - 'jest/valid-title': 'warn', - '@wordpress/no-global-active-element': 'warn', - 'no-unused-vars': [ - 'error', - { - varsIgnorePattern: 'createElement', - }, - ], - 'react/react-in-jsx-scope': 'error', - }, - overrides: [ - { - files: [ '*.ts', '*.tsx' ], - parser: '@typescript-eslint/parser', - extends: [ - 'plugin:@woocommerce/eslint-plugin/recommended', - 'plugin:@typescript-eslint/recommended', - ], - rules: { - camelcase: 'off', - '@typescript-eslint/no-explicit-any': 'error', - 'no-use-before-define': 'off', - '@typescript-eslint/no-use-before-define': [ 'error' ], - 'jsdoc/require-param': 'off', - // Making use of typescript no-shadow instead, fixes issues with enum. - 'no-shadow': 'off', - '@typescript-eslint/no-shadow': [ 'error' ], - '@typescript-eslint/no-empty-function': 'off', - }, - }, - { - files: [ - '**/stories/*.js', - '**/stories/*.jsx', - '**/docs/example.js', - ], - rules: { - 'react/react-in-jsx-scope': 'off', - }, - }, - ], -}; diff --git a/packages/js/admin-e2e-tests/.eslintrc.js b/packages/js/admin-e2e-tests/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/admin-e2e-tests/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/components/.eslintrc.js b/packages/js/components/.eslintrc.js new file mode 100644 index 00000000000..f740ae8d831 --- /dev/null +++ b/packages/js/components/.eslintrc.js @@ -0,0 +1,19 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, + overrides: [ + { + files: [ + '**/stories/*.js', + '**/stories/*.jsx', + '**/docs/example.js', + ], + rules: { + 'import/no-unresolved': [ + 'warn', + { ignore: [ '@woocommerce/components' ] }, + ], + }, + }, + ], +}; diff --git a/packages/js/components/package.json b/packages/js/components/package.json index bc68739b90d..e8369cdf545 100644 --- a/packages/js/components/package.json +++ b/packages/js/components/package.json @@ -115,7 +115,7 @@ "build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "build:css": "webpack", "clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*", - "lint": "eslint src", + "lint": "eslint src --ext=js,ts,tsx", "prepack": "pnpm run clean && pnpm run build", "start": "concurrently \"tsc --build ./tsconfig.json --watch\" \"webpack --watch\"", "test": "pnpm run build && pnpm run test:nobuild", diff --git a/packages/js/csv-export/.eslintrc.js b/packages/js/csv-export/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/csv-export/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/currency/.eslintrc.js b/packages/js/currency/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/currency/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/customer-effort-score/.eslintrc.js b/packages/js/customer-effort-score/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/customer-effort-score/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/data/.eslintrc.js b/packages/js/data/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/data/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/date/.eslintrc.js b/packages/js/date/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/date/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/dependency-extraction-webpack-plugin/.eslintrc.js b/packages/js/dependency-extraction-webpack-plugin/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/dependency-extraction-webpack-plugin/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/dependency-extraction-webpack-plugin/package.json b/packages/js/dependency-extraction-webpack-plugin/package.json index 6add7dbe320..eccc6705f2b 100644 --- a/packages/js/dependency-extraction-webpack-plugin/package.json +++ b/packages/js/dependency-extraction-webpack-plugin/package.json @@ -25,6 +25,8 @@ }, "devDependencies": { "@babel/core": "^7.17.5", + "@wordpress/eslint-plugin": "^11.0.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jest-cli": "^27.5.1", "rimraf": "^3.0.2", diff --git a/packages/js/eslint-plugin/.eslintrc.js b/packages/js/eslint-plugin/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/eslint-plugin/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/eslint-plugin/package.json b/packages/js/eslint-plugin/package.json index 4a5f70e1495..787d6b7011d 100644 --- a/packages/js/eslint-plugin/package.json +++ b/packages/js/eslint-plugin/package.json @@ -28,7 +28,6 @@ "dependencies": { "@typescript-eslint/parser": "^5.14.0", "@wordpress/eslint-plugin": "^11.0.0", - "eslint": "^8.10.0", "eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-testing-library": "^5.1.0", "requireindex": "^1.2.0" @@ -36,8 +35,12 @@ "publishConfig": { "access": "public" }, + "scripts": { + "lint": "eslint ./rules ./configs" + }, "devDependencies": { "@babel/core": "^7.17.5", + "eslint": "^8.11.0", "jest": "^27.5.1", "jest-cli": "^27.5.1", "rimraf": "^3.0.2", diff --git a/packages/js/experimental/.eslintrc.js b/packages/js/experimental/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/experimental/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/explat/.eslintrc.js b/packages/js/explat/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/explat/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/js-tests/.eslintrc.js b/packages/js/js-tests/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/js-tests/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/navigation/.eslintrc.js b/packages/js/navigation/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/navigation/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/notices/.eslintrc.js b/packages/js/notices/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/notices/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/number/.eslintrc.js b/packages/js/number/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/number/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/onboarding/.eslintrc.js b/packages/js/onboarding/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/onboarding/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/style-build/.eslintrc.js b/packages/js/style-build/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/style-build/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +}; diff --git a/packages/js/tracks/.eslintrc.js b/packages/js/tracks/.eslintrc.js new file mode 100644 index 00000000000..e4d185d8cd1 --- /dev/null +++ b/packages/js/tracks/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], + root: true, +};