Skip to content

Commit

Permalink
fix: validated - add linter for inclusive language and fix all the er…
Browse files Browse the repository at this point in the history
…rors (#2992)
  • Loading branch information
rajeshtezu authored Aug 8, 2023
1 parent f40e4dd commit c1b7072
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 65 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion eslintrules/rules/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 28 additions & 28 deletions eslintrules/rules/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,83 +24,83 @@ 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',
// jsx: 'never'
// }],

// 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',
Expand All @@ -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',
{
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions eslintrules/rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy/eslint/static/rules/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit c1b7072

Please sign in to comment.