Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: alphabetize ESLint rules #19100

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 87 additions & 105 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,80 @@ module.exports = {
},
],
rules: {
// Possible Errors
// http://eslint.org/docs/rules/#possible-errors
// ESLint built-in rules
// http://eslint.org/docs/rules
'accessor-pairs': 'error',
'array-callback-return': 'error',
'arrow-parens': ['error', 'always'],
'arrow-spacing': ['error', { before: true, after: true }],
'block-spacing': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-dangle': ['error', 'only-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
'constructor-super': 'error',
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'eol-last': 'error',
eqeqeq: ['error', 'smart'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason some of these are ' quoted and others not? If not, can we pick one style and be consistent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely prefer it be consistent and intend to introduce a lint rule requiring that (if someone doesn't beat me to it). Was going to wait for this to land first to keep the pull requests minimal and focused. By waiting for this to land first, we avoid a merge conflict.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing they're quoted as needed for object properties.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't like that and would prefer that they all be quoted for consistency if one needs to be quoted. But that's just a preference. My plan is to try to figure out what the most common practice is in the code base, and then enforce that. If it's what's going on here, then so be it.

'for-direction': 'error',
'func-call-spacing': 'error',
'func-name-matching': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
indent: ['error', 2, {
ArrayExpression: 'first',
CallExpression: { arguments: 'first' },
FunctionDeclaration: { parameters: 'first' },
FunctionExpression: { parameters: 'first' },
MemberExpression: 'off',
ObjectExpression: 'first',
SwitchCase: 1,
}],
'key-spacing': ['error', { mode: 'strict' }],
'keyword-spacing': 'error',
'linebreak-style': ['error', 'unix'],
'max-len': ['error', {
code: 80,
ignorePattern: '^// Flags:',
ignoreRegExpLiterals: true,
ignoreUrls: true,
tabWidth: 2,
}],
'new-parens': 'error',
'no-class-assign': 'error',
'no-confusing-arrow': 'error',
'no-const-assign': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': ['error', 'functions'],
'no-extra-semi': 'error',
'no-fallthrough': 'error',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-obj-calls': 'error',
'no-template-curly-in-string': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-negation': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',

// Best Practices
// http://eslint.org/docs/rules/#best-practices
'accessor-pairs': 'error',
'array-callback-return': 'error',
'dot-location': ['error', 'property'],
'dot-notation': 'error',
eqeqeq: ['error', 'smart'],
'no-fallthrough': 'error',
'no-global-assign': 'error',
'no-lonely-if': 'error',
'no-mixed-requires': 'error',
'no-mixed-spaces-and-tabs': 'error',
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
'no-new-require': 'error',
'no-new-symbol': 'error',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-path-concat': 'error',
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-modules': ['error', 'sys'],
'no-restricted-properties': [
'error',
{
Expand Down Expand Up @@ -110,76 +147,6 @@ module.exports = {
message: '__defineSetter__ is deprecated.',
}
],
'no-return-await': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-unused-labels': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-with': 'error',

// Strict Mode
// http://eslint.org/docs/rules/#strict-mode
strict: ['error', 'global'],

// Variables
// http://eslint.org/docs/rules/#variables
'no-delete-var': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-unused-vars': ['error', { args: 'none' }],
'no-use-before-define': ['error', {
classes: true,
functions: false,
variables: false,
}],

// Node.js and CommonJS
// http://eslint.org/docs/rules/#nodejs-and-commonjs
'no-mixed-requires': 'error',
'no-new-require': 'error',
'no-path-concat': 'error',
'no-restricted-modules': ['error', 'sys'],

// Stylistic Issues
// http://eslint.org/docs/rules/#stylistic-issues'
'block-spacing': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-dangle': ['error', 'only-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
'eol-last': 'error',
'func-call-spacing': 'error',
'func-name-matching': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
indent: ['error', 2, {
ArrayExpression: 'first',
CallExpression: { arguments: 'first' },
FunctionDeclaration: { parameters: 'first' },
FunctionExpression: { parameters: 'first' },
MemberExpression: 'off',
ObjectExpression: 'first',
SwitchCase: 1,
}],
'key-spacing': ['error', { mode: 'strict' }],
'keyword-spacing': 'error',
'linebreak-style': ['error', 'unix'],
'max-len': ['error', {
code: 80,
ignorePattern: '^// Flags:',
ignoreRegExpLiterals: true,
ignoreUrls: true,
tabWidth: 2,
}],
'new-parens': 'error',
'no-lonely-if': 'error',
'no-mixed-spaces-and-tabs': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
/* eslint-disable max-len, quotes */
'no-restricted-syntax': [
'error',
Expand Down Expand Up @@ -209,15 +176,41 @@ module.exports = {
}
],
/* eslint-enable max-len, quotes */
'no-return-await': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-tabs': 'error',
'no-template-curly-in-string': 'error',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unused-labels': 'error',
'no-unused-vars': ['error', { args: 'none' }],
'no-use-before-define': ['error', {
classes: true,
functions: false,
variables: false,
}],
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-whitespace-before-property': 'error',
'no-with': 'error',
'object-curly-spacing': ['error', 'always'],
'one-var': ['error', { initialized: 'never' }],
'one-var-declaration-per-line': 'error',
'operator-linebreak': ['error', 'after'],
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
quotes: ['error', 'single', { avoidEscape: true }],
'rest-spread-spacing': 'error',
semi: 'error',
'semi-spacing': 'error',
'space-before-blocks': ['error', 'always'],
Expand All @@ -229,25 +222,14 @@ module.exports = {
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'unicode-bom': 'error',

// ECMAScript 6
// http://eslint.org/docs/rules/#ecmascript-6
'arrow-parens': ['error', 'always'],
'arrow-spacing': ['error', { before: true, after: true }],
'constructor-super': 'error',
'no-class-assign': 'error',
'no-confusing-arrow': 'error',
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-new-symbol': 'error',
'no-this-before-super': 'error',
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
'rest-spread-spacing': 'error',
strict: ['error', 'global'],
'symbol-description': 'error',
'template-curly-spacing': 'error',
'unicode-bom': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',

// Custom rules in from eslint-plugin-node-core
// Custom rules from eslint-plugin-node-core
'node-core/no-unescaped-regexp-dot': 'error',
},
globals: {
Expand Down