Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamguo committed Dec 22, 2023
1 parent ef746e4 commit a9ad1a4
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 152 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module.exports = {
{ avoidEscape: true, allowTemplateLiterals: false },
],
},
parserOptions: {
ecmaVersion: "latest",
},
},
{
files: ["**/*.test.js"],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build/
/node_modules/
/test-config/
/.idea/
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Example ESLint configuration:

### [lines-around-comment] \(deprecated)

(The following applies to [@typescript-eslint/lines-around-comment] as well.)
(The following applies to [@stylistic/lines-around-comment], [@stylistic/js/lines-around-comment], [@stylistic/ts/lines-around-comment], and[@typescript-eslint/lines-around-comment] as well.)

**This rule can be used with certain options.**

Expand Down Expand Up @@ -336,7 +336,7 @@ Example ESLint configuration:

### [max-len] \(deprecated)

(The following applies to [vue/max-len] as well.)
(The following applies to [@stylistic/max-len], [@stylistic/js/max-len], and [vue/max-len] as well.)

**This rule requires special attention when writing code.**

Expand All @@ -359,6 +359,8 @@ Example ESLint configuration:

### [no-confusing-arrow] \(deprecated)

(The following applies to [@stylistic/no-confusing-arrow] and [@stylistic/js/no-confusing-arrow] as well.)

**This rule requires certain options.**

For example, the rule could warn about this line:
Expand Down Expand Up @@ -409,6 +411,8 @@ Example ESLint configuration:

### [no-mixed-operators] \(deprecated)

(The following applies to [@stylistic/no-mixed-operators] and [@stylistic/js/no-mixed-operators] as well.)

**This rule requires special attention when writing code.**

This rule forbids mixing certain operators, such as `&&` and `||`.
Expand Down Expand Up @@ -462,6 +466,8 @@ Example ESLint configuration:

### [no-tabs] \(deprecated)

(The following applies to [@stylistic/no-tabs] and [@stylistic/js/no-tabs] as well.)

**This rule requires certain options.**

This rule disallows the use of tab characters. By default the rule forbids _all_ tab characters. That can be used just fine with Prettier as long as you don’t configure Prettier to indent using tabs.
Expand Down Expand Up @@ -548,7 +554,7 @@ Example configuration:

### [quotes] \(deprecated)

(The following applies to [babel/quotes] and [@typescript-eslint/quotes] as well.)
(The following applies to [babel/quotes], [@stylistic/quotes], [@stylistic/js/quotes], [@stylistic/ts/quotes], and [@typescript-eslint/quotes] as well.)

**This rule requires certain options and certain Prettier options.**

Expand Down Expand Up @@ -853,6 +859,20 @@ When you’re done, run `npm test` to verify that you got it all right. It runs
[MIT](LICENSE).

[@babel/eslint-plugin]: https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin
[@stylistic/lines-around-comment]: https://eslint.style/rules/default/lines-around-comment
[@stylistic/js/lines-around-comment]: https://eslint.style/rules/js/lines-around-comment
[@stylistic/ts/lines-around-comment]: https://eslint.style/rules/ts/lines-around-comment
[@stylistic/max-len]: https://eslint.style/rules/default/max-len
[@stylistic/js/max-len]: https://eslint.style/rules/js/max-len
[@stylistic/no-confusing-arrow]: https://eslint.style/rules/default/no-confusing-arrow
[@stylistic/js/no-confusing-arrow]: https://eslint.style/rules/js/no-confusing-arrow
[@stylistic/no-mixed-operators]: https://eslint.style/rules/default/no-mixed-operators
[@stylistic/js/no-mixed-operators]: https://eslint.style/rules/js/no-mixed-operators
[@stylistic/no-tabs]: https://eslint.style/rules/default/no-tabs
[@stylistic/js/no-tabs]: https://eslint.style/rules/js/no-tabs
[@stylistic/quotes]: https://eslint.style/rules/default/quotes
[@stylistic/js/quotes]: https://eslint.style/rules/js/quotes
[@stylistic/ts/quotes]: https://eslint.style/rules/ts/quotes
[@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
[@typescript-eslint/lines-around-comment]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-around-comment.md
[@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
Expand Down
11 changes: 11 additions & 0 deletions eslint.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const google = require("eslint-config-google");
const prettier = require("eslint-plugin-prettier");
const react = require("eslint-plugin-react");
const standard = require("eslint-plugin-standard");
const stylistic = require("@stylistic/eslint-plugin");
const stylisticJs = require("@stylistic/eslint-plugin-js");
const stylisticTs = require("@stylistic/eslint-plugin-ts");
const stylisticJsx = require("@stylistic/eslint-plugin-jsx");
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
const unicorn = require("eslint-plugin-unicorn");
const vue = require("eslint-plugin-vue");
Expand Down Expand Up @@ -42,6 +46,10 @@ module.exports = [
prettier,
react,
standard,
"@stylistic": stylistic,
"@stylistic/js": stylisticJs,
"@stylistic/ts": stylisticTs,
"@stylistic/jsx": stylisticJsx,
unicorn,
vue,
},
Expand All @@ -53,6 +61,9 @@ module.exports = [
{
rules: react.configs.all.rules,
},
{
rules: stylistic.configs["all-flat"].rules,
},
{
rules: unicorn.configs.recommended.rules,
},
Expand Down
22 changes: 13 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ module.exports = [
{
rules: eslintrc.rules,
},
...eslintrc.overrides.map(({ env = {}, ...override }) => ({
...override,
languageOptions: {
globals: Object.entries(env).reduce(
(acc, [key, enabled]) => (enabled ? { ...acc, ...globals[key] } : acc),
{}
),
},
})),
...eslintrc.overrides.map(
({ env = {}, parserOptions = {}, ...override }) => ({
...override,
languageOptions: {
globals: Object.entries(env).reduce(
(acc, [key, enabled]) =>
enabled ? { ...acc, ...globals[key] } : acc,
{}
),
parserOptions,
},
})
),
];
180 changes: 180 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ module.exports = {
// in the deprecated section below.
"curly": specialRule,
"no-unexpected-multiline": specialRule,
"@stylistic/lines-around-comment": specialRule,
"@stylistic/max-len": specialRule,
"@stylistic/no-confusing-arrow": specialRule,
"@stylistic/no-mixed-operators": specialRule,
"@stylistic/no-tabs": specialRule,
"@stylistic/quotes": specialRule,
"@stylistic/js/lines-around-comment": specialRule,
"@stylistic/js/max-len": specialRule,
"@stylistic/js/no-confusing-arrow": specialRule,
"@stylistic/js/no-mixed-operators": specialRule,
"@stylistic/js/no-tabs": specialRule,
"@stylistic/js/quotes": specialRule,
"@stylistic/ts/lines-around-comment": specialRule,
"@stylistic/ts/quotes": specialRule,
"@typescript-eslint/lines-around-comment": specialRule,
"@typescript-eslint/quotes": specialRule,
"babel/quotes": specialRule,
Expand All @@ -22,6 +36,172 @@ module.exports = {
// The rest are rules that you never need to enable when using Prettier.
"@babel/object-curly-spacing": "off",
"@babel/semi": "off",
"@stylistic/array-bracket-newline": "off",
"@stylistic/array-bracket-spacing": "off",
"@stylistic/array-element-newline": "off",
"@stylistic/arrow-parens": "off",
"@stylistic/arrow-spacing": "off",
"@stylistic/block-spacing": "off",
"@stylistic/brace-style": "off",
"@stylistic/comma-dangle": "off",
"@stylistic/comma-spacing": "off",
"@stylistic/comma-style": "off",
"@stylistic/computed-property-spacing": "off",
"@stylistic/dot-location": "off",
"@stylistic/eol-last": "off",
"@stylistic/func-call-spacing": "off",
"@stylistic/function-call-argument-newline": "off",
"@stylistic/function-call-spacing": "off",
"@stylistic/function-paren-newline": "off",
"@stylistic/generator-star-spacing": "off",
"@stylistic/implicit-arrow-linebreak": "off",
"@stylistic/indent": "off",
"@stylistic/jsx-quotes": "off",
"@stylistic/key-spacing": "off",
"@stylistic/keyword-spacing": "off",
"@stylistic/linebreak-style": "off",
"@stylistic/max-statements-per-line": "off",
"@stylistic/multiline-ternary": "off",
"@stylistic/new-parens": "off",
"@stylistic/newline-per-chained-call": "off",
"@stylistic/no-extra-parens": "off",
"@stylistic/no-extra-semi": "off",
"@stylistic/no-floating-decimal": "off",
"@stylistic/no-mixed-spaces-and-tabs": "off",
"@stylistic/no-multi-spaces": "off",
"@stylistic/no-multiple-empty-lines": "off",
"@stylistic/no-trailing-spaces": "off",
"@stylistic/no-whitespace-before-property": "off",
"@stylistic/nonblock-statement-body-position": "off",
"@stylistic/object-curly-newline": "off",
"@stylistic/object-curly-spacing": "off",
"@stylistic/object-property-newline": "off",
"@stylistic/one-var-declaration-per-line": "off",
"@stylistic/operator-linebreak": "off",
"@stylistic/padded-blocks": "off",
"@stylistic/quote-props": "off",
"@stylistic/rest-spread-spacing": "off",
"@stylistic/semi": "off",
"@stylistic/semi-spacing": "off",
"@stylistic/semi-style": "off",
"@stylistic/space-before-blocks": "off",
"@stylistic/space-before-function-paren": "off",
"@stylistic/space-in-parens": "off",
"@stylistic/space-infix-ops": "off",
"@stylistic/space-unary-ops": "off",
"@stylistic/switch-colon-spacing": "off",
"@stylistic/template-curly-spacing": "off",
"@stylistic/template-tag-spacing": "off",
"@stylistic/wrap-iife": "off",
"@stylistic/wrap-regex": "off",
"@stylistic/yield-star-spacing": "off",
"@stylistic/member-delimiter-style": "off",
"@stylistic/type-annotation-spacing": "off",
"@stylistic/jsx-child-element-spacing": "off",
"@stylistic/jsx-closing-bracket-location": "off",
"@stylistic/jsx-closing-tag-location": "off",
"@stylistic/jsx-curly-newline": "off",
"@stylistic/jsx-curly-spacing": "off",
"@stylistic/jsx-equals-spacing": "off",
"@stylistic/jsx-first-prop-new-line": "off",
"@stylistic/jsx-indent": "off",
"@stylistic/jsx-indent-props": "off",
"@stylistic/jsx-max-props-per-line": "off",
"@stylistic/jsx-newline": "off",
"@stylistic/jsx-one-expression-per-line": "off",
"@stylistic/jsx-props-no-multi-spaces": "off",
"@stylistic/jsx-tag-spacing": "off",
"@stylistic/jsx-wrap-multilines": "off",
"@stylistic/indent-binary-ops": "off",
"@stylistic/type-generic-spacing": "off",
"@stylistic/type-named-tuple-spacing": "off",
"@stylistic/js/array-bracket-newline": "off",
"@stylistic/js/array-bracket-spacing": "off",
"@stylistic/js/array-element-newline": "off",
"@stylistic/js/arrow-parens": "off",
"@stylistic/js/arrow-spacing": "off",
"@stylistic/js/block-spacing": "off",
"@stylistic/js/brace-style": "off",
"@stylistic/js/comma-dangle": "off",
"@stylistic/js/comma-spacing": "off",
"@stylistic/js/comma-style": "off",
"@stylistic/js/computed-property-spacing": "off",
"@stylistic/js/dot-location": "off",
"@stylistic/js/eol-last": "off",
"@stylistic/js/func-call-spacing": "off",
"@stylistic/js/function-call-argument-newline": "off",
"@stylistic/js/function-call-spacing": "off",
"@stylistic/js/function-paren-newline": "off",
"@stylistic/js/generator-star-spacing": "off",
"@stylistic/js/implicit-arrow-linebreak": "off",
"@stylistic/js/indent": "off",
"@stylistic/js/jsx-quotes": "off",
"@stylistic/js/key-spacing": "off",
"@stylistic/js/keyword-spacing": "off",
"@stylistic/js/linebreak-style": "off",
"@stylistic/js/max-statements-per-line": "off",
"@stylistic/js/multiline-ternary": "off",
"@stylistic/js/new-parens": "off",
"@stylistic/js/newline-per-chained-call": "off",
"@stylistic/js/no-extra-parens": "off",
"@stylistic/js/no-extra-semi": "off",
"@stylistic/js/no-floating-decimal": "off",
"@stylistic/js/no-mixed-spaces-and-tabs": "off",
"@stylistic/js/no-multi-spaces": "off",
"@stylistic/js/no-multiple-empty-lines": "off",
"@stylistic/js/no-trailing-spaces": "off",
"@stylistic/js/no-whitespace-before-property": "off",
"@stylistic/js/nonblock-statement-body-position": "off",
"@stylistic/js/object-curly-newline": "off",
"@stylistic/js/object-curly-spacing": "off",
"@stylistic/js/object-property-newline": "off",
"@stylistic/js/one-var-declaration-per-line": "off",
"@stylistic/js/operator-linebreak": "off",
"@stylistic/js/padded-blocks": "off",
"@stylistic/js/quote-props": "off",
"@stylistic/js/rest-spread-spacing": "off",
"@stylistic/js/semi": "off",
"@stylistic/js/semi-spacing": "off",
"@stylistic/js/semi-style": "off",
"@stylistic/js/space-before-blocks": "off",
"@stylistic/js/space-before-function-paren": "off",
"@stylistic/js/space-in-parens": "off",
"@stylistic/js/space-infix-ops": "off",
"@stylistic/js/space-unary-ops": "off",
"@stylistic/js/switch-colon-spacing": "off",
"@stylistic/js/template-curly-spacing": "off",
"@stylistic/js/template-tag-spacing": "off",
"@stylistic/js/wrap-iife": "off",
"@stylistic/js/wrap-regex": "off",
"@stylistic/js/yield-star-spacing": "off",
"@stylistic/ts/block-spacing": "off",
"@stylistic/ts/brace-style": "off",
"@stylistic/ts/comma-dangle": "off",
"@stylistic/ts/comma-spacing": "off",
"@stylistic/ts/func-call-spacing": "off",
"@stylistic/ts/function-call-spacing": "off",
"@stylistic/ts/indent": "off",
"@stylistic/ts/key-spacing": "off",
"@stylistic/ts/keyword-spacing": "off",
"@stylistic/ts/member-delimiter-style": "off",
"@stylistic/ts/no-extra-parens": "off",
"@stylistic/ts/no-extra-semi": "off",
"@stylistic/ts/object-curly-spacing": "off",
"@stylistic/ts/semi": "off",
"@stylistic/ts/space-before-blocks": "off",
"@stylistic/ts/space-before-function-paren": "off",
"@stylistic/ts/space-infix-ops": "off",
"@stylistic/ts/type-annotation-spacing": "off",
"@stylistic/jsx/jsx-child-element-spacing": "off",
"@stylistic/jsx/jsx-closing-bracket-location": "off",
"@stylistic/jsx/jsx-closing-tag-location": "off",
"@stylistic/jsx/jsx-curly-newline": "off",
"@stylistic/jsx/jsx-curly-spacing": "off",
"@stylistic/jsx/jsx-equals-spacing": "off",
"@stylistic/jsx/jsx-first-prop-new-line": "off",
"@stylistic/jsx/jsx-indent": "off",
"@stylistic/jsx/jsx-indent-props": "off",
"@stylistic/jsx/jsx-max-props-per-line": "off",
"@typescript-eslint/block-spacing": "off",
"@typescript-eslint/brace-style": "off",
"@typescript-eslint/comma-dangle": "off",
Expand Down
Loading

0 comments on commit a9ad1a4

Please sign in to comment.