Skip to content

Commit

Permalink
add support for eslint-stylistic
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamguo committed Dec 4, 2023
1 parent 4f3bbb4 commit 96ff3b1
Show file tree
Hide file tree
Showing 3 changed files with 892 additions and 7,023 deletions.
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/
232 changes: 134 additions & 98 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ const includeDeprecated = !process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED;

const specialRule = 0;

const disableRulesInCoreAndStylistic = (
corePrefix,
stylisticPrefix,
regularRules,
specialRules
) =>
Object.fromEntries(
[corePrefix, "@stylistic/", `@stylistic/${stylisticPrefix}/`].flatMap(
(prefix) =>
[
...regularRules.map((rule) => [rule, "off"]),
...specialRules.map((rule) => [rule, specialRule]),
].map(([rule, severity]) => [prefix + rule, severity])
)
);

module.exports = {
rules: {
// The following rules can be used in some cases. See the README for more
Expand All @@ -12,8 +28,6 @@ module.exports = {
// in the deprecated section below.
"curly": specialRule,
"no-unexpected-multiline": specialRule,
"@typescript-eslint/lines-around-comment": specialRule,
"@typescript-eslint/quotes": specialRule,
"babel/quotes": specialRule,
"unicorn/template-indent": specialRule,
"vue/html-self-closing": specialRule,
Expand All @@ -22,23 +36,30 @@ module.exports = {
// The rest are rules that you never need to enable when using Prettier.
"@babel/object-curly-spacing": "off",
"@babel/semi": "off",
"@typescript-eslint/block-spacing": "off",
"@typescript-eslint/brace-style": "off",
"@typescript-eslint/comma-dangle": "off",
"@typescript-eslint/comma-spacing": "off",
"@typescript-eslint/func-call-spacing": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/key-spacing": "off",
"@typescript-eslint/keyword-spacing": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/object-curly-spacing": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/space-before-blocks": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/space-infix-ops": "off",
"@typescript-eslint/type-annotation-spacing": "off",
...disableRulesInCoreAndStylistic(
"@typescript-eslint/",
"ts",
[
"block-spacing",
"brace-style",
"comma-dangle",
"comma-spacing",
"func-call-spacing",
"indent",
"key-spacing",
"keyword-spacing",
"member-delimiter-style",
"no-extra-parens",
"no-extra-semi",
"object-curly-spacing",
"semi",
"space-before-blocks",
"space-before-function-paren",
"space-infix-ops",
"type-annotation-spacing",
],
["lines-around-comment", "quotes"]
),
"babel/object-curly-spacing": "off",
"babel/semi": "off",
"flowtype/boolean-style": "off",
Expand All @@ -52,21 +73,28 @@ module.exports = {
"flowtype/space-before-generic-bracket": "off",
"flowtype/space-before-type-colon": "off",
"flowtype/union-intersection-spacing": "off",
"react/jsx-child-element-spacing": "off",
"react/jsx-closing-bracket-location": "off",
"react/jsx-closing-tag-location": "off",
"react/jsx-curly-newline": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-first-prop-new-line": "off",
"react/jsx-indent": "off",
"react/jsx-indent-props": "off",
"react/jsx-max-props-per-line": "off",
"react/jsx-newline": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-props-no-multi-spaces": "off",
"react/jsx-tag-spacing": "off",
"react/jsx-wrap-multilines": "off",
...disableRulesInCoreAndStylistic(
"react/",
"jsx",
[
"jsx-child-element-spacing",
"jsx-closing-bracket-location",
"jsx-closing-tag-location",
"jsx-curly-newline",
"jsx-curly-spacing",
"jsx-equals-spacing",
"jsx-first-prop-new-line",
"jsx-indent",
"jsx-indent-props",
"jsx-max-props-per-line",
"jsx-newline",
"jsx-one-expression-per-line",
"jsx-props-no-multi-spaces",
"jsx-tag-spacing",
"jsx-wrap-multilines",
],
[]
),
"standard/array-bracket-even-spacing": "off",
"standard/computed-property-even-spacing": "off",
"standard/object-curly-even-spacing": "off",
Expand Down Expand Up @@ -144,70 +172,78 @@ module.exports = {

// Deprecated since version 8.53.0.
// https://eslint.org/blog/2023/10/deprecating-formatting-rules/
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
"array-element-newline": "off",
"arrow-parens": "off",
"arrow-spacing": "off",
"block-spacing": "off",
"brace-style": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"computed-property-spacing": "off",
"dot-location": "off",
"eol-last": "off",
"func-call-spacing": "off",
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"generator-star-spacing": "off",
"implicit-arrow-linebreak": "off",
"indent": "off",
"jsx-quotes": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": "off",
"lines-around-comment": specialRule,
"max-len": specialRule,
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-confusing-arrow": specialRule,
"no-extra-parens": "off",
"no-extra-semi": "off",
"no-floating-decimal": "off",
"no-mixed-operators": specialRule,
"no-mixed-spaces-and-tabs": "off",
"no-multi-spaces": "off",
"no-multiple-empty-lines": "off",
"no-tabs": specialRule,
"no-trailing-spaces": "off",
"no-whitespace-before-property": "off",
"nonblock-statement-body-position": "off",
"object-curly-newline": "off",
"object-curly-spacing": "off",
"object-property-newline": "off",
"one-var-declaration-per-line": "off",
"operator-linebreak": "off",
"padded-blocks": "off",
"quote-props": "off",
"quotes": specialRule,
"rest-spread-spacing": "off",
"semi": "off",
"semi-spacing": "off",
"semi-style": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "off",
"switch-colon-spacing": "off",
"template-curly-spacing": "off",
"template-tag-spacing": "off",
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "off",
...disableRulesInCoreAndStylistic(
"",
"js",
[
"array-bracket-newline",
"array-bracket-spacing",
"array-element-newline",
"arrow-parens",
"arrow-spacing",
"block-spacing",
"brace-style",
"comma-dangle",
"comma-spacing",
"comma-style",
"computed-property-spacing",
"dot-location",
"eol-last",
"func-call-spacing",
"function-call-argument-newline",
"function-paren-newline",
"generator-star-spacing",
"implicit-arrow-linebreak",
"indent",
"jsx-quotes",
"key-spacing",
"keyword-spacing",
"linebreak-style",
"max-statements-per-line",
"multiline-ternary",
"new-parens",
"newline-per-chained-call",
"no-extra-parens",
"no-extra-semi",
"no-floating-decimal",
"no-mixed-spaces-and-tabs",
"no-multi-spaces",
"no-multiple-empty-lines",
"no-trailing-spaces",
"no-whitespace-before-property",
"nonblock-statement-body-position",
"object-curly-newline",
"object-curly-spacing",
"object-property-newline",
"one-var-declaration-per-line",
"operator-linebreak",
"padded-blocks",
"quote-props",
"rest-spread-spacing",
"semi",
"semi-spacing",
"semi-style",
"space-before-blocks",
"space-before-function-paren",
"space-in-parens",
"space-infix-ops",
"space-unary-ops",
"switch-colon-spacing",
"template-curly-spacing",
"template-tag-spacing",
"wrap-iife",
"wrap-regex",
"yield-star-spacing",
],
[
"lines-around-comment",
"max-len",
"no-confusing-arrow",
"no-mixed-operators",
"no-tabs",
"quotes",
]
),

// Deprecated since version 7.0.0.
// https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#700---2017-05-06
Expand Down
Loading

0 comments on commit 96ff3b1

Please sign in to comment.