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

Support ESLint new config system #1886

Merged
merged 35 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c55bd34
feat: support new config system
jjangga0214 Sep 10, 2022
27459a7
Update index.mjs
sindresorhus Sep 10, 2022
612da7d
Update recommended.mjs
sindresorhus Sep 10, 2022
580fa29
refactor: rm dup
jjangga0214 Sep 10, 2022
33f11c8
style: format
jjangga0214 Sep 11, 2022
dfd5159
feat: add languageOptions and files to the new config
jjangga0214 Sep 11, 2022
0084e5e
style: format
jjangga0214 Sep 11, 2022
ff1cacf
refactor: import dup
jjangga0214 Sep 13, 2022
8dff114
docs: guide the new config system
jjangga0214 Sep 13, 2022
5f4d2a0
docs: align a word
jjangga0214 Sep 13, 2022
9c9afff
fix: path to configs-legacy
jjangga0214 Sep 14, 2022
c7c4a94
docs: globals -> languageOptions.globals
jjangga0214 Sep 15, 2022
30a8bc0
Update readme.md
sindresorhus Sep 20, 2022
6a1659b
Update readme.md
sindresorhus Sep 20, 2022
dce48df
docs: fix style
jjangga0214 Sep 21, 2022
8d87f54
Merge branch 'main' into feat/new-config-system
jjangga0214 Sep 21, 2022
34a3ecc
Merge branch 'main' into feat/new-config-system
fisker Dec 20, 2023
4f92045
Switch back to commonjs
fisker Dec 20, 2023
6689394
Fix file name
fisker Dec 20, 2023
24093f2
Fix config
fisker Dec 20, 2023
c8180d4
Add test
fisker Dec 20, 2023
37b3aa1
Fix
fisker Dec 20, 2023
d35eb36
Update readme.md
fisker Dec 20, 2023
165e34d
Fix anchor
fisker Dec 20, 2023
3e46955
Fix linting
fisker Dec 20, 2023
0942d71
Linting
fisker Dec 20, 2023
4b3b487
Fix example
fisker Dec 20, 2023
b099569
Remove useless dependency
fisker Dec 20, 2023
3809656
Fix anchor
fisker Dec 20, 2023
8985321
Use auto generated anchor
fisker Dec 20, 2023
151b3fd
Move to `flat/*`
fisker Dec 20, 2023
dce3053
Fix create-rule.mjs
fisker Dec 20, 2023
2161a47
Open editor
fisker Dec 20, 2023
9452c7f
Update .eslint-doc-generatorrc.js
fisker Dec 20, 2023
3895cc7
Update package.json
sindresorhus Dec 20, 2023
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
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions configs/all.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import recommended from './recommended.mjs'

export default {
...recommended,
rules: Object.fromEntries(Object.entries(recommended.rules).map(
([ruleId, severity]) => [ruleId, ruleId.startsWith('unicorn/') ? 'error' : severity],
)),
}
119 changes: 119 additions & 0 deletions configs/recommended.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import unicorn from '../index.mjs'

export default {
plugins: {
unicorn,
},
rules: {
'unicorn/better-regex': 'error',
'unicorn/catch-error-name': 'error',
'unicorn/consistent-destructuring': 'error',
'unicorn/consistent-function-scoping': 'error',
'unicorn/custom-error-definition': 'off',
'unicorn/empty-brace-spaces': 'error',
'unicorn/error-message': 'error',
'unicorn/escape-case': 'error',
'unicorn/expiring-todo-comments': 'error',
'unicorn/explicit-length-check': 'error',
'unicorn/filename-case': 'error',
'unicorn/import-style': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/no-array-callback-reference': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-array-method-this-argument': 'error',
'unicorn/no-array-push-push': 'error',
'unicorn/no-array-reduce': 'error',
'unicorn/no-await-expression-member': 'error',
'unicorn/no-console-spaces': 'error',
'unicorn/no-document-cookie': 'error',
'unicorn/no-empty-file': 'error',
'unicorn/no-for-loop': 'error',
'unicorn/no-hex-escape': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-invalid-remove-event-listener': 'error',
'unicorn/no-keyword-prefix': 'off',
'unicorn/no-lonely-if': 'error',
'no-nested-ternary': 'off',
'unicorn/no-nested-ternary': 'error',
'unicorn/no-new-array': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-null': 'error',
'unicorn/no-object-as-default-parameter': 'error',
'unicorn/no-process-exit': 'error',
'unicorn/no-static-only-class': 'error',
'unicorn/no-thenable': 'error',
'unicorn/no-this-assignment': 'error',
'unicorn/no-unreadable-array-destructuring': 'error',
'unicorn/no-unreadable-iife': 'error',
'unicorn/no-unsafe-regex': 'off',
'unicorn/no-unused-properties': 'off',
'unicorn/no-useless-fallback-in-spread': 'error',
'unicorn/no-useless-length-check': 'error',
'unicorn/no-useless-promise-resolve-reject': 'error',
'unicorn/no-useless-spread': 'error',
'unicorn/no-useless-switch-case': 'error',
'unicorn/no-useless-undefined': 'error',
'unicorn/no-zero-fractions': 'error',
'unicorn/number-literal-case': 'error',
'unicorn/numeric-separators-style': 'error',
'unicorn/prefer-add-event-listener': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-index-of': 'error',
'unicorn/prefer-array-some': 'error',
// TODO: Enable this by default when targeting a Node.js version that supports `Array#at`.
'unicorn/prefer-at': 'off',
'unicorn/prefer-code-point': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
// TODO: Enable this by default when targeting Node.js 16.
'unicorn/prefer-event-target': 'off',
'unicorn/prefer-export-from': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-json-parse-buffer': 'off',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-logical-operator-over-ternary': 'error',
'unicorn/prefer-math-trunc': 'error',
'unicorn/prefer-modern-dom-apis': 'error',
'unicorn/prefer-modern-math-apis': 'error',
'unicorn/prefer-module': 'error',
'unicorn/prefer-native-coercion-functions': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-node-protocol': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-object-from-entries': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/prefer-prototype-methods': 'error',
'unicorn/prefer-query-selector': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-set-has': 'error',
'unicorn/prefer-spread': 'error',
// TODO: Enable this by default when targeting Node.js 16.
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-string-slice': 'error',
'unicorn/prefer-string-starts-ends-with': 'error',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-switch': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-top-level-await': 'error',
'unicorn/prefer-type-error': 'error',
'unicorn/prevent-abbreviations': 'error',
'unicorn/relative-url-style': 'error',
'unicorn/require-array-join-separator': 'error',
'unicorn/require-number-to-fixed-digits-argument': 'error',
// Turned off because we can't distinguish `widow.postMessage` and `{Worker,MessagePort,Client,BroadcastChannel}#postMessage()`
// See #1396
'unicorn/require-post-message-target-origin': 'off',
'unicorn/string-content': 'off',
'unicorn/template-indent': 'error',
'unicorn/text-encoding-identifier-case': 'error',
'unicorn/throw-new-error': 'error',
},
};
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
const createDeprecatedRules = require('./rules/utils/create-deprecated-rules.js');
const {loadRules} = require('./rules/utils/rule.js');
const recommendedConfig = require('./configs/recommended.js');
const allRulesEnabledConfig = require('./configs/all.js');
const recommendedConfig = require('./configs-legacy/recommended.js');
const allRulesEnabledConfig = require('./configs-legacy/all.js');

const deprecatedRules = createDeprecatedRules({
// {ruleId: ReplacementRuleId | ReplacementRuleId[]}, if no replacement, use `{ruleId: []}`
Expand Down
29 changes: 29 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import createDeprecatedRules from './rules/utils/create-deprecated-rules.js';
import { loadRules } from './rules/utils/rule.js';

const deprecatedRules = createDeprecatedRules({
// {ruleId: ReplacementRuleId | ReplacementRuleId[]}, if no replacement, use `{ruleId: []}`
'import-index': [],
'no-array-instanceof': 'unicorn/no-instanceof-array',
'no-fn-reference-in-iterator': 'unicorn/no-array-callback-reference',
'no-reduce': 'unicorn/no-array-reduce',
'prefer-dataset': 'unicorn/prefer-dom-node-dataset',
'prefer-event-key': 'unicorn/prefer-keyboard-event-key',
'prefer-exponentiation-operator': 'prefer-exponentiation-operator',
'prefer-flat-map': 'unicorn/prefer-array-flat-map',
'prefer-node-append': 'unicorn/prefer-dom-node-append',
'prefer-node-remove': 'unicorn/prefer-dom-node-remove',
'prefer-object-has-own': 'prefer-object-has-own',
'prefer-replace-all': 'unicorn/prefer-string-replace-all',
'prefer-starts-ends-with': 'unicorn/prefer-string-starts-ends-with',
'prefer-text-content': 'unicorn/prefer-dom-node-text-content',
'prefer-trim-start-end': 'unicorn/prefer-string-trim-start-end',
'regex-shorthand': 'unicorn/better-regex',
});

export default {
rules: {
...loadRules(),
...deprecatedRules,
},
}
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
"engines": {
"node": ">=14.18"
},
"main": "index.js",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
},
"./all": "./configs/all.mjs",
"./recommended": "./configs/recommended.mjs",
"./package.json": "./package.json"
fisker marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"create-rule": "node ./scripts/create-rule.mjs && npm run generate-rule-notices && npm run generate-rules-table",
"fix": "run-p --continue-on-error fix:*",
Expand All @@ -32,8 +42,10 @@
},
"files": [
"index.js",
"experimental.mjs",
"rules",
"configs"
"configs",
"configs-legacy"
],
"keywords": [
"eslint",
Expand Down