Skip to content

Commit

Permalink
feat: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
preco21 committed Mar 1, 2024
1 parent 133101b commit 32868b4
Show file tree
Hide file tree
Showing 20 changed files with 464 additions and 38 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
es6: true,
},
parserOptions: {
ecmaVersion: 2019,
ecmaVersion: 'latest',
sourceType: 'module',
},
extends: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"node": true
},
"parserOptions": {
"ecmaVersion": 2019,
"ecmaVersion": "latest",
"sourceType": "script"
}
}
Expand Down
2 changes: 1 addition & 1 deletion react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
es6: true,
},
parserOptions: {
ecmaVersion: 2019,
ecmaVersion: 'latest',
sourceType: 'module',
},
extends: [
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ For example:
"node": true
},
"parserOptions": {
"ecmaVersion": 2019,
"ecmaVersion": "latest",
"sourceType": "module"
},
"extends": [
Expand Down
141 changes: 141 additions & 0 deletions rules/base/layout-formatting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
'use strict';

// DEPRECATED except unicode-bom and line-comment-position

// https://eslint.org/blog/2023/10/deprecating-formatting-rules/

/**
* Layout & Formatting
* https://eslint.org/docs/latest/rules/#layout--formatting
*/
module.exports = {
rules: {
'no-extra-parens': ['error', 'all', {
conditionalAssign: false,
returnAssign: false,
nestedBinaryExpressions: false,
ignoreJSX: 'all',
enforceForArrowConditionals: false,
enforceForSequenceExpressions: false,
enforceForNewInMemberExpressions: false,
enforceForFunctionPrototypeMethods: false,
}],
'dot-location': ['error', 'property'],
'no-multi-spaces': 'error',
// The `functionPrototypeMethods` option is enabled because using such
// expression without any assignment will end up in a syntax error as it may
// seem as a function declaration.
'wrap-iife': ['error', 'inside', { functionPrototypeMethods: true }],
'array-bracket-newline': ['error', 'consistent'],
'array-bracket-spacing': 'error',
'array-element-newline': ['error', 'consistent'],
'block-spacing': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': ['error', 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
},
}],
'computed-property-spacing': 'error',
'eol-last': 'error',
'func-call-spacing': 'error',
'function-call-argument-newline': ['error', 'consistent'],
// FIXME: Disabled due to the issue where it triggers false-positive in
// multiline generic functions in TypeScript.
// https://github.com/typescript-eslint/typescript-eslint/issues/942
'function-paren-newline': 'off',
// We encourage you to use long-form style function body when writing a
// function that contains long content which may be formed in multiline or
// break down into statements. doing so, you can manage the line length of
// code easily, resulting more readable code.
// use `() => { return LONG_CONTENT; }` instead of `() => LONG_CONTENT`
// or `() => (<JSXContent />)` in JSX
'implicit-arrow-linebreak': 'error',
'indent': ['error', 2, { SwitchCase: 1 }],
'jsx-quotes': 'off',
'key-spacing': 'error',
'keyword-spacing': 'error',
'line-comment-position': 'off',
'linebreak-style': 'error',
'lines-around-comment': 'off',
// For long strings, you can use multiline string concatenation
// as `no-useless-concat` rule allows it. if you need string interpolation,
// you can use it in conjunction with template literals:
// 'very-long-class-name ' +
// 'another-long-class-name ' + `modifier-${x}`
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'max-len': ['warn', {
code: 100,
tabWidth: 2,
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
}],
'max-statements-per-line': 'off',
'multiline-ternary': ['error', 'always-multiline'],
// FIXME:
// disabled due to the issue where it causes some conflict with
// the fixer of `@typescript-eslint/comma-dangle` rule
// { a: new Date } -> { a: new Date,() }
'new-parens': 'off',
'newline-per-chained-call': 'off',
// Since we enforce separate variable declarations via `one-var` rule
// and `key-spacing rule for aligning properties with arbitrary spaces, it's
// safe to not include `smart-tabs` option.
'no-mixed-spaces-and-tabs': 'error',
// leading and trailing empty lines may be trimmed by text editor
'no-multiple-empty-lines': 'error',
'no-tabs': 'error',
// leading and trailing spaces may be trimmed by text editor
'no-trailing-spaces': 'warn',
'no-whitespace-before-property': 'error',
// since our `curly` rule doesn't allow any nonblock-statement, we can
// safely disable this rule.
'nonblock-statement-body-position': 'off',
// this rule doesn't really help placing braces in the right position.
// also, you often need to express object merging with spread syntax like this:
// const next = { ...existing,
// extra: 'foo',
// };
'object-curly-newline': 'off',
'object-curly-spacing': ['error', 'always'],
'object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
'operator-linebreak': 'error',
'padded-blocks': ['error', 'never', { allowSingleLineBlocks: true }],
'padding-line-between-statements': 'off',
// allowing double quotes for some edge cases, but always prefer single quotes
'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'semi': 'error',
'semi-spacing': 'error',
'semi-style': 'error',
'switch-colon-spacing': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'template-tag-spacing': 'error',
'unicode-bom': 'error',
'wrap-regex': 'off',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'generator-star-spacing': ['error', { before: false, after: true }],
'rest-spread-spacing': 'error',
'template-curly-spacing': 'error',
'yield-star-spacing': 'error',
},
};
79 changes: 79 additions & 0 deletions rules/base/possible-problems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict';

/**
* Possible Problems
* https://eslint.org/docs/latest/rules/#possible-problems
*/
module.exports = {
rules: {
'array-callback-return': 'error',
'constructor-super': 'error',
'for-direction': 'error',
'getter-return': 'error',
'no-async-promise-executor': 'error',
// You may need to use `await` in loops for various purposes such as
// indefinite iteration, retrying (e.g., exponential backoff), throttling,
// and running a series of workflow jobs sequentially.
'no-await-in-loop': 'off',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-const-assign': 'error',
'no-constant-binary-expression': 'error',
// Use `for (;;) {}` for infinite loop
'no-constant-condition': 'warn',
'no-constructor-return': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'off',
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-ex-assign': 'error',
'no-fallthrough': 'error',
'no-func-assign': 'error',
'no-import-assign': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-loss-of-precision': 'warn',
'no-misleading-character-class': 'error',
'no-new-native-nonconstructor': 'error',
'no-new-symbol': 'error',
'no-obj-calls': 'error',
// This rule is disabled for situations where you may encounter edge cases while using `setTimeout()`, such as:
// await new Promise((resolve) => setTimeout(resolve, 300));
'no-promise-executor-return': 'off',
'no-prototype-builtins': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-setter-return': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-this-before-super': 'error',
'no-undef': 'error',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'error',
'no-unreachable-loop': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unsafe-optional-chaining': 'error',
'no-unused-private-class-members': 'error',
'no-unused-vars': ['error', {
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
}],
'no-use-before-define': ['error', { functions: false, variables: false }],
'no-useless-backreference': 'error',
// FIXME: Enable once this issue is resolved: https://github.com/eslint/eslint/issues/11899
'require-atomic-updates': 'off',
'use-isnan': 'error',
'valid-typeof': ['error', { requireStringLiterals: true }],
},
};
Loading

0 comments on commit 32868b4

Please sign in to comment.