From c1b7072653ad0635fb803e93d69283df4f6e1ec1 Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Tue, 8 Aug 2023 10:35:22 +0530 Subject: [PATCH] fix: validated - add linter for inclusive language and fix all the errors (#2992) --- .eslintrc.js | 10 +++- eslintrules/rules/es6.js | 2 +- eslintrules/rules/imports.js | 56 +++++++++---------- eslintrules/rules/style.js | 6 +- package.json | 1 + packages/legacy/eslint/static/rules/es6.js | 2 +- .../legacy/eslint/static/rules/imports.js | 56 +++++++++---------- packages/legacy/eslint/static/rules/style.js | 6 +- yarn.lock | 17 ++++++ 9 files changed, 91 insertions(+), 65 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index bfd8dad53ec..5ac3b99b3bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,7 +14,14 @@ module.exports = { PACKAGE_VERSION: false, WebSocket: false, }, - plugins: ['import', 'eslint-plugin-tsdoc', 'jest', 'prettier', 'chai-friendly'], + plugins: [ + 'import', + 'eslint-plugin-tsdoc', + 'jest', + 'prettier', + 'chai-friendly', + 'inclusive-language', + ], extends: [ 'eslint:recommended', './eslintrules/index.js', @@ -258,6 +265,7 @@ module.exports = { 'import/no-cycle': 1, // TODO: Fix this in a later PR 'class-methods-use-this': 1, // TODO: Fix this in a later PR 'import/no-extraneous-dependencies': 1, // TODO: Fix this in a later PR + 'inclusive-language/use-inclusive-words': 'error', }, settings: { diff --git a/eslintrules/rules/es6.js b/eslintrules/rules/es6.js index ea0e1210f90..e5cde3a592b 100644 --- a/eslintrules/rules/es6.js +++ b/eslintrules/rules/es6.js @@ -56,7 +56,7 @@ module.exports = { // disallow importing from the same path more than once // https://eslint.org/docs/rules/no-duplicate-imports - // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + // replaced by https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md 'no-duplicate-imports': 'off', // disallow symbol constructor diff --git a/eslintrules/rules/imports.js b/eslintrules/rules/imports.js index 7caabd66f1c..0ff927bab0c 100644 --- a/eslintrules/rules/imports.js +++ b/eslintrules/rules/imports.js @@ -24,75 +24,75 @@ module.exports = { // Static analysis: // ensure named imports coupled with named exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/named.md#when-not-to-use-it 'import/named': 'error', // ensure default import coupled with default export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/default.md#when-not-to-use-it 'import/default': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/namespace.md 'import/namespace': 'off', // Helpful warnings: // disallow invalid exports, e.g. multiple defaults - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/export.md 'import/export': 'error', // do not allow a default import name to match a named export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md 'import/no-named-as-default': 'error', // warn on accessing default export property names that are also named exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md 'import/no-named-as-default-member': 'error', // disallow use of jsdoc-marked-deprecated imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md 'import/no-deprecated': 'off', // Forbid mutable exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md 'import/no-mutable-exports': 'error', // Module systems: // disallow require() - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-commonjs.md 'import/no-commonjs': 'off', // disallow AMD require/define - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-amd.md 'import/no-amd': 'error', // No Node.js builtin modules - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md // TODO: enable? 'import/no-nodejs-modules': 'off', // Style guide: // disallow non-import statements appearing before import statements - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/first.md 'import/first': ['error', 'absolute-first'], // disallow non-import statements appearing before import statements - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/imports-first.md // deprecated: use `import/first` 'import/imports-first': 'off', // disallow duplicate imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md 'import/no-duplicates': 'error', // disallow namespace imports // TODO: enable? - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-namespace.md 'import/no-namespace': 'off', // Ensure consistent use of file extension within the import path - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/extensions.md // Disabling for now until next version of plugin supports ignorePackages // 'import/extensions': ['error', 'always', { // js: 'never', @@ -100,7 +100,7 @@ module.exports = { // }], // Enforce a convention in module import order - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/order.md // TODO: enable? 'import/order': [ 'error', @@ -111,31 +111,31 @@ module.exports = { ], // Require a newline after the last import/require in a group - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md 'import/newline-after-import': 'error', // Require modules with a single export to use a default export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md 'import/prefer-default-export': 'error', // Restrict which files can be imported in a given folder - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md 'import/no-restricted-paths': 'off', // Forbid modules to have too many dependencies - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/max-dependencies.md 'import/max-dependencies': ['off', {max: 10}], // Forbid import of modules using absolute paths - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md 'import/no-absolute-path': 'error', // Forbid require() calls with expressions - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-dynamic-require.md 'import/no-dynamic-require': 'error', // prevent importing the submodules of other modules - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-internal-modules.md 'import/no-internal-modules': [ 'off', { @@ -145,22 +145,22 @@ module.exports = { // Warn if a module could be mistakenly parsed as a script by a consumer // leveraging Unambiguous JavaScript Grammar - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/unambiguous.md // this should not be enabled until this proposal has at least been *presented* to TC39. // At the moment, it's not a thing. 'import/unambiguous': 'off', // Forbid Webpack loader syntax in imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-webpack-loader-syntax.md 'import/no-webpack-loader-syntax': 'error', // Prevent unassigned imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-unassigned-import.md // importing for side effects is perfectly acceptable, if you need side effects. 'import/no-unassigned-import': 'off', // Prevent importing the default as if it were named - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-default.md 'import/no-named-default': 'error', // Reports if a module's default export is unnamed diff --git a/eslintrules/rules/style.js b/eslintrules/rules/style.js index 7bfed5b90e3..45547c738c3 100644 --- a/eslintrules/rules/style.js +++ b/eslintrules/rules/style.js @@ -88,9 +88,9 @@ module.exports = { // https://eslint.org/docs/rules/function-paren-newline 'function-paren-newline': ['error', 'consistent'], - // Blacklist certain identifiers to prevent them being used - // https://eslint.org/docs/rules/id-blacklist - 'id-blacklist': 'off', + // Disallow specified identifiers + // https://eslint.org/docs/rules/id-denylist + 'id-denylist': 'off', // this option enforces minimum and maximum identifier lengths // (variable names, property names etc.) diff --git a/package.json b/package.json index 7cbc11aa2ef..4448b1aff5a 100644 --- a/package.json +++ b/package.json @@ -137,6 +137,7 @@ "eslint-import-resolver-typescript": "^2.4.0", "eslint-plugin-chai-friendly": "^0.7.2", "eslint-plugin-import": "^2.26.0", + "eslint-plugin-inclusive-language": "^2.2.0", "eslint-plugin-jasmine": "^4.1.3", "eslint-plugin-jest": "^26.1.1", "eslint-plugin-jsdoc": "^40.0.0", diff --git a/packages/legacy/eslint/static/rules/es6.js b/packages/legacy/eslint/static/rules/es6.js index ea0e1210f90..e5cde3a592b 100644 --- a/packages/legacy/eslint/static/rules/es6.js +++ b/packages/legacy/eslint/static/rules/es6.js @@ -56,7 +56,7 @@ module.exports = { // disallow importing from the same path more than once // https://eslint.org/docs/rules/no-duplicate-imports - // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + // replaced by https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md 'no-duplicate-imports': 'off', // disallow symbol constructor diff --git a/packages/legacy/eslint/static/rules/imports.js b/packages/legacy/eslint/static/rules/imports.js index 7caabd66f1c..0ff927bab0c 100644 --- a/packages/legacy/eslint/static/rules/imports.js +++ b/packages/legacy/eslint/static/rules/imports.js @@ -24,75 +24,75 @@ module.exports = { // Static analysis: // ensure named imports coupled with named exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/named.md#when-not-to-use-it 'import/named': 'error', // ensure default import coupled with default export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/default.md#when-not-to-use-it 'import/default': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/namespace.md 'import/namespace': 'off', // Helpful warnings: // disallow invalid exports, e.g. multiple defaults - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/export.md 'import/export': 'error', // do not allow a default import name to match a named export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md 'import/no-named-as-default': 'error', // warn on accessing default export property names that are also named exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md 'import/no-named-as-default-member': 'error', // disallow use of jsdoc-marked-deprecated imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md 'import/no-deprecated': 'off', // Forbid mutable exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md 'import/no-mutable-exports': 'error', // Module systems: // disallow require() - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-commonjs.md 'import/no-commonjs': 'off', // disallow AMD require/define - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-amd.md 'import/no-amd': 'error', // No Node.js builtin modules - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md // TODO: enable? 'import/no-nodejs-modules': 'off', // Style guide: // disallow non-import statements appearing before import statements - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/first.md 'import/first': ['error', 'absolute-first'], // disallow non-import statements appearing before import statements - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/imports-first.md // deprecated: use `import/first` 'import/imports-first': 'off', // disallow duplicate imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md 'import/no-duplicates': 'error', // disallow namespace imports // TODO: enable? - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-namespace.md 'import/no-namespace': 'off', // Ensure consistent use of file extension within the import path - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/extensions.md // Disabling for now until next version of plugin supports ignorePackages // 'import/extensions': ['error', 'always', { // js: 'never', @@ -100,7 +100,7 @@ module.exports = { // }], // Enforce a convention in module import order - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/order.md // TODO: enable? 'import/order': [ 'error', @@ -111,31 +111,31 @@ module.exports = { ], // Require a newline after the last import/require in a group - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md 'import/newline-after-import': 'error', // Require modules with a single export to use a default export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md 'import/prefer-default-export': 'error', // Restrict which files can be imported in a given folder - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md 'import/no-restricted-paths': 'off', // Forbid modules to have too many dependencies - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/max-dependencies.md 'import/max-dependencies': ['off', {max: 10}], // Forbid import of modules using absolute paths - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md 'import/no-absolute-path': 'error', // Forbid require() calls with expressions - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-dynamic-require.md 'import/no-dynamic-require': 'error', // prevent importing the submodules of other modules - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-internal-modules.md 'import/no-internal-modules': [ 'off', { @@ -145,22 +145,22 @@ module.exports = { // Warn if a module could be mistakenly parsed as a script by a consumer // leveraging Unambiguous JavaScript Grammar - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/unambiguous.md // this should not be enabled until this proposal has at least been *presented* to TC39. // At the moment, it's not a thing. 'import/unambiguous': 'off', // Forbid Webpack loader syntax in imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-webpack-loader-syntax.md 'import/no-webpack-loader-syntax': 'error', // Prevent unassigned imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-unassigned-import.md // importing for side effects is perfectly acceptable, if you need side effects. 'import/no-unassigned-import': 'off', // Prevent importing the default as if it were named - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md + // https://github.com/benmosher/eslint-plugin-import/blob/main/docs/rules/no-named-default.md 'import/no-named-default': 'error', // Reports if a module's default export is unnamed diff --git a/packages/legacy/eslint/static/rules/style.js b/packages/legacy/eslint/static/rules/style.js index 7bfed5b90e3..45547c738c3 100644 --- a/packages/legacy/eslint/static/rules/style.js +++ b/packages/legacy/eslint/static/rules/style.js @@ -88,9 +88,9 @@ module.exports = { // https://eslint.org/docs/rules/function-paren-newline 'function-paren-newline': ['error', 'consistent'], - // Blacklist certain identifiers to prevent them being used - // https://eslint.org/docs/rules/id-blacklist - 'id-blacklist': 'off', + // Disallow specified identifiers + // https://eslint.org/docs/rules/id-denylist + 'id-denylist': 'off', // this option enforces minimum and maximum identifier lengths // (variable names, property names etc.) diff --git a/yarn.lock b/yarn.lock index 151eda82008..2fc23f4c53e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12060,6 +12060,15 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-inclusive-language@npm:^2.2.0": + version: 2.2.0 + resolution: "eslint-plugin-inclusive-language@npm:2.2.0" + dependencies: + humps: ^2.0.1 + checksum: 23094560b750cb8200382ac12faba00dda9cd882d42fe9f40777986699cc29a077bc6dfef0519c23f26753993d016fb8c206e0501e30de4858473f753e11a94b + languageName: node + linkType: hard + "eslint-plugin-jasmine@npm:^4.1.3": version: 4.1.3 resolution: "eslint-plugin-jasmine@npm:4.1.3" @@ -14812,6 +14821,13 @@ __metadata: languageName: node linkType: hard +"humps@npm:^2.0.1": + version: 2.0.1 + resolution: "humps@npm:2.0.1" + checksum: 7d5a674cfca2f34c04562f6fd0d129b4c43a5caf85fcc1c9eacf5d0729554c9375db362c4232519b37369c94dd2560d85f96ad4091a8fbf4af4e625ab5214a30 + languageName: node + linkType: hard + "husky@npm:^7.0.4": version: 7.0.4 resolution: "husky@npm:7.0.4" @@ -25902,6 +25918,7 @@ __metadata: eslint-import-resolver-typescript: ^2.4.0 eslint-plugin-chai-friendly: ^0.7.2 eslint-plugin-import: ^2.26.0 + eslint-plugin-inclusive-language: ^2.2.0 eslint-plugin-jasmine: ^4.1.3 eslint-plugin-jest: ^26.1.1 eslint-plugin-jsdoc: ^40.0.0