@aiou/eslint-config 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/index.cjs +163 -129
- package/dist/index.mjs +163 -129
- package/dts/configs/comments.d.ts +2 -2
- package/dts/configs/ignores.d.ts +2 -2
- package/dts/configs/imports.d.ts +2 -2
- package/dts/configs/javascript.d.ts +2 -2
- package/dts/configs/jsonc.d.ts +2 -2
- package/dts/configs/markdown.d.ts +2 -2
- package/dts/configs/next.d.ts +2 -2
- package/dts/configs/progress.d.ts +2 -2
- package/dts/configs/react.d.ts +3 -2
- package/dts/configs/stylistic.d.ts +2 -0
- package/dts/configs/tailwindcss.d.ts +2 -2
- package/dts/configs/typescript.d.ts +2 -2
- package/dts/configs/unicorn.d.ts +2 -2
- package/dts/configs/yml.d.ts +2 -2
- package/dts/index.d.ts +6 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -33,6 +33,14 @@ const { aiou } = require('@aiou/eslint-config')
|
|
|
33
33
|
|
|
34
34
|
module.exports = aiou()
|
|
35
35
|
```
|
|
36
|
+
|
|
37
|
+
### options
|
|
38
|
+
|
|
39
|
+
#### `options.ssr`
|
|
40
|
+
|
|
41
|
+
- default: `false`
|
|
42
|
+
|
|
43
|
+
enabled ssr-friendly rules
|
|
36
44
|
|
|
37
45
|
## rules
|
|
38
46
|
|
|
@@ -54,10 +62,11 @@ eslint-plugin-promise
|
|
|
54
62
|
eslint-plugin-unicorn
|
|
55
63
|
eslint-plugin-yml
|
|
56
64
|
eslint-plugin-react
|
|
57
|
-
eslint-plugin-ssr-friendly
|
|
65
|
+
eslint-plugin-ssr-friendly (configured when ssr enabled)
|
|
58
66
|
eslint-plugin-react-refresh
|
|
59
67
|
@next/eslint-plugin-next (enabled when next found)
|
|
60
68
|
eslint-plugin-react-hooks
|
|
61
69
|
eslint-plugin-tailwindcss
|
|
62
70
|
@typescript-eslint/eslint-plugin
|
|
71
|
+
@stylistic/eslint-plugin
|
|
63
72
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var pluginReact = require('eslint-plugin-react');
|
|
|
20
20
|
var pluginReactHooks = require('eslint-plugin-react-hooks');
|
|
21
21
|
var pluginReactRefresh = require('eslint-plugin-react-refresh');
|
|
22
22
|
var pluginSSRFriendly = require('eslint-plugin-ssr-friendly');
|
|
23
|
+
var pluginStylistic = require('@stylistic/eslint-plugin');
|
|
23
24
|
var node_module = require('node:module');
|
|
24
25
|
var pluginTypeScript = require('@typescript-eslint/eslint-plugin');
|
|
25
26
|
var tsParser = require('@typescript-eslint/parser');
|
|
@@ -58,6 +59,7 @@ const GLOB_TEST_DIRS = "**/{test,tests,e2e,__test__,__tests__}/**";
|
|
|
58
59
|
const GLOB_DTS = "**/*.d.ts";
|
|
59
60
|
const GLOB_TS = "**/*.?([cm])ts";
|
|
60
61
|
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
62
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
61
63
|
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
62
64
|
const GLOB_JSON = "**/*.json";
|
|
63
65
|
const GLOB_JSON5 = "**/*.json5";
|
|
@@ -149,7 +151,9 @@ const imports = () => {
|
|
|
149
151
|
{
|
|
150
152
|
files: [
|
|
151
153
|
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
152
|
-
`**/{pages,routes}/**/*.${GLOB_SCRIPT_EXT}`,
|
|
154
|
+
`**/{app,pages,routes}/**/*.${GLOB_SCRIPT_EXT}`,
|
|
155
|
+
`**/App*.${GLOB_SCRIPT_EXT}`,
|
|
156
|
+
`**/Document.${GLOB_SCRIPT_EXT}`,
|
|
153
157
|
"**/{vite,esbuild,rollup,webpack,rspack}.ts",
|
|
154
158
|
GLOB_DTS
|
|
155
159
|
],
|
|
@@ -838,39 +842,21 @@ const javascript = () => {
|
|
|
838
842
|
rules: {
|
|
839
843
|
...pluginStandard.rules,
|
|
840
844
|
...pluginRegexp.configs.recommended.rules,
|
|
841
|
-
// Common
|
|
842
|
-
semi: ["error", "never"],
|
|
843
|
-
// Always need {}
|
|
844
845
|
curly: ["error", "all"],
|
|
845
|
-
quotes: ["error", "single"],
|
|
846
|
-
"quote-props": ["error", "as-needed"],
|
|
847
846
|
"no-unused-vars": "warn",
|
|
848
847
|
"no-param-reassign": "off",
|
|
849
|
-
"array-bracket-spacing": ["error", "never"],
|
|
850
|
-
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
851
|
-
"brace-style": ["error", "1tbs"],
|
|
852
|
-
"block-spacing": ["error", "always"],
|
|
853
848
|
camelcase: "off",
|
|
854
|
-
"comma-spacing": ["error", { before: false, after: true }],
|
|
855
|
-
"comma-style": ["error", "last"],
|
|
856
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
857
849
|
"no-constant-condition": "warn",
|
|
858
850
|
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
859
851
|
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
860
852
|
"no-cond-assign": ["error", "always"],
|
|
861
|
-
"func-call-spacing": ["off", "never"],
|
|
862
|
-
"key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
863
|
-
// https://github.com/prettier/prettier-eslint/issues/226
|
|
864
|
-
indent: ["error", 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
|
|
865
853
|
"no-restricted-syntax": [
|
|
866
854
|
"error",
|
|
867
855
|
"DebuggerStatement",
|
|
868
856
|
"LabeledStatement",
|
|
869
857
|
"WithStatement"
|
|
870
858
|
],
|
|
871
|
-
"object-curly-spacing": ["error", "always"],
|
|
872
859
|
"no-return-await": "off",
|
|
873
|
-
"space-before-function-paren": ["error", "never"],
|
|
874
860
|
// es6
|
|
875
861
|
"no-var": "error",
|
|
876
862
|
"prefer-const": [
|
|
@@ -899,9 +885,7 @@ const javascript = () => {
|
|
|
899
885
|
"prefer-rest-params": "error",
|
|
900
886
|
"prefer-spread": "error",
|
|
901
887
|
"prefer-template": "error",
|
|
902
|
-
"template-curly-spacing": "error",
|
|
903
888
|
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
904
|
-
"generator-star-spacing": "off",
|
|
905
889
|
// best-practice
|
|
906
890
|
"array-callback-return": "error",
|
|
907
891
|
"block-scoped-var": "error",
|
|
@@ -910,15 +894,13 @@ const javascript = () => {
|
|
|
910
894
|
eqeqeq: ["error", "allow-null"],
|
|
911
895
|
"no-alert": "warn",
|
|
912
896
|
"no-case-declarations": "error",
|
|
913
|
-
"no-multi-spaces": "error",
|
|
914
897
|
"no-multi-str": "error",
|
|
915
898
|
"no-with": "error",
|
|
916
899
|
"no-void": "error",
|
|
917
900
|
"no-useless-escape": "off",
|
|
918
901
|
"vars-on-top": "error",
|
|
919
902
|
"require-await": "off",
|
|
920
|
-
"no-return-assign": "off"
|
|
921
|
-
"operator-linebreak": ["error", "before"]
|
|
903
|
+
"no-return-assign": "off"
|
|
922
904
|
}
|
|
923
905
|
}
|
|
924
906
|
];
|
|
@@ -1189,7 +1171,6 @@ const markdown = () => {
|
|
|
1189
1171
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1190
1172
|
"@typescript-eslint/no-use-before-define": "off",
|
|
1191
1173
|
"@typescript-eslint/no-var-requires": "off",
|
|
1192
|
-
"@typescript-eslint/comma-dangle": "off",
|
|
1193
1174
|
"@typescript-eslint/consistent-type-imports": "off",
|
|
1194
1175
|
"@typescript-eslint/no-namespace": "off",
|
|
1195
1176
|
"@typescript-eslint/no-require-imports": "off",
|
|
@@ -4006,21 +3987,158 @@ const react = () => {
|
|
|
4006
3987
|
plugins: {
|
|
4007
3988
|
react: pluginReact,
|
|
4008
3989
|
"react-hooks": pluginReactHooks,
|
|
4009
|
-
"ssr-friendly": pluginSSRFriendly,
|
|
4010
3990
|
"react-refresh": pluginReactRefresh
|
|
4011
3991
|
},
|
|
4012
3992
|
rules: {
|
|
4013
3993
|
...pluginReact.configs.recommended.rules,
|
|
4014
3994
|
...pluginReact.configs["jsx-runtime"].rules,
|
|
4015
3995
|
...pluginReactHooks.configs.recommended.rules,
|
|
4016
|
-
...pluginSSRFriendly.configs.recommended.rules,
|
|
4017
|
-
"jsx-quotes": ["error", "prefer-double"],
|
|
4018
3996
|
"react/prop-types": "off",
|
|
4019
3997
|
"react/no-unescaped-entities": "off",
|
|
4020
3998
|
"react/no-unknown-property": "off",
|
|
4021
3999
|
"react/jsx-boolean-value": ["error", "always"],
|
|
4000
|
+
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
4001
|
+
"react-refresh/only-export-components": "warn"
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
];
|
|
4005
|
+
return config;
|
|
4006
|
+
};
|
|
4007
|
+
const ssrReact = () => {
|
|
4008
|
+
const config = [
|
|
4009
|
+
{
|
|
4010
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
4011
|
+
languageOptions: {
|
|
4012
|
+
parserOptions: {
|
|
4013
|
+
...pluginReact.configs.recommended.parserOptions,
|
|
4014
|
+
...pluginReact.configs["jsx-runtime"].parserOptions
|
|
4015
|
+
}
|
|
4016
|
+
},
|
|
4017
|
+
settings: {
|
|
4018
|
+
react: {
|
|
4019
|
+
// 'detect' will throw warn on monorepo
|
|
4020
|
+
version: "18.0"
|
|
4021
|
+
}
|
|
4022
|
+
},
|
|
4023
|
+
plugins: {
|
|
4024
|
+
"ssr-friendly": pluginSSRFriendly
|
|
4025
|
+
},
|
|
4026
|
+
rules: {
|
|
4027
|
+
...pluginSSRFriendly.configs.recommended.rules
|
|
4028
|
+
}
|
|
4029
|
+
},
|
|
4030
|
+
{
|
|
4031
|
+
files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
|
|
4032
|
+
rules: {
|
|
4033
|
+
...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
|
|
4034
|
+
"ssr-friendly/only-export-components": "off"
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
];
|
|
4038
|
+
return config;
|
|
4039
|
+
};
|
|
4040
|
+
|
|
4041
|
+
const stylistic = () => {
|
|
4042
|
+
const config = pluginStylistic.configs.customize({
|
|
4043
|
+
flat: true,
|
|
4044
|
+
indent: 2,
|
|
4045
|
+
jsx: true,
|
|
4046
|
+
quotes: "single",
|
|
4047
|
+
semi: false
|
|
4048
|
+
});
|
|
4049
|
+
const off = {};
|
|
4050
|
+
Object.keys(config.rules).forEach((key) => {
|
|
4051
|
+
off[key.replace("@stylistic/", "")] = "off";
|
|
4052
|
+
});
|
|
4053
|
+
const configs = [
|
|
4054
|
+
{
|
|
4055
|
+
files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
|
|
4056
|
+
plugins: {
|
|
4057
|
+
...config.plugins
|
|
4058
|
+
},
|
|
4059
|
+
rules: {
|
|
4060
|
+
...off,
|
|
4061
|
+
...config.rules,
|
|
4062
|
+
"@stylistic/quotes": ["error", "single"],
|
|
4063
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
4064
|
+
"@stylistic/array-bracket-spacing": ["error", "never"],
|
|
4065
|
+
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
4066
|
+
"@stylistic/brace-style": ["error", "1tbs"],
|
|
4067
|
+
"@stylistic/block-spacing": ["error", "always"],
|
|
4068
|
+
"@stylistic/comma-spacing": ["error", { before: false, after: true }],
|
|
4069
|
+
"@stylistic/comma-style": ["error", "last"],
|
|
4070
|
+
"comma-dangle": "off",
|
|
4071
|
+
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
|
4072
|
+
"@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
4073
|
+
"@stylistic/indent": ["error", 2, {
|
|
4074
|
+
SwitchCase: 1,
|
|
4075
|
+
VariableDeclarator: 1,
|
|
4076
|
+
outerIIFEBody: 1,
|
|
4077
|
+
MemberExpression: 1,
|
|
4078
|
+
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
4079
|
+
FunctionExpression: { parameters: 1, body: 1 },
|
|
4080
|
+
CallExpression: { arguments: 1 },
|
|
4081
|
+
ArrayExpression: 1,
|
|
4082
|
+
ObjectExpression: 1,
|
|
4083
|
+
ImportDeclaration: 1,
|
|
4084
|
+
flatTernaryExpressions: false,
|
|
4085
|
+
ignoreComments: false,
|
|
4086
|
+
ignoredNodes: [
|
|
4087
|
+
"TemplateLiteral *",
|
|
4088
|
+
"JSXElement",
|
|
4089
|
+
"JSXElement > *",
|
|
4090
|
+
"JSXAttribute",
|
|
4091
|
+
"JSXIdentifier",
|
|
4092
|
+
"JSXNamespacedName",
|
|
4093
|
+
"JSXMemberExpression",
|
|
4094
|
+
"JSXSpreadAttribute",
|
|
4095
|
+
"JSXExpressionContainer",
|
|
4096
|
+
"JSXOpeningElement",
|
|
4097
|
+
"JSXClosingElement",
|
|
4098
|
+
"JSXFragment",
|
|
4099
|
+
"JSXOpeningFragment",
|
|
4100
|
+
"JSXClosingFragment",
|
|
4101
|
+
"JSXText",
|
|
4102
|
+
"JSXEmptyExpression",
|
|
4103
|
+
"JSXSpreadChild",
|
|
4104
|
+
"TSTypeParameterInstantiation",
|
|
4105
|
+
"FunctionExpression > .params[decorators.length > 0]",
|
|
4106
|
+
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
4107
|
+
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
4108
|
+
],
|
|
4109
|
+
offsetTernaryExpressions: true
|
|
4110
|
+
}],
|
|
4111
|
+
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
4112
|
+
"@stylistic/template-curly-spacing": "error",
|
|
4113
|
+
"@stylistic/generator-star-spacing": "off",
|
|
4114
|
+
"@stylistic/no-multi-spaces": "error",
|
|
4115
|
+
"@stylistic/operator-linebreak": ["error", "before"],
|
|
4116
|
+
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
4117
|
+
"@stylistic/type-annotation-spacing": ["error", {}],
|
|
4118
|
+
// no-spaced-func alert -- https://eslint.org/docs/latest/rules/no-spaced-func
|
|
4119
|
+
"@stylistic/func-call-spacing": ["error", "never"],
|
|
4120
|
+
"@stylistic/semi": ["error", "never"],
|
|
4121
|
+
"@stylistic/space-before-blocks": ["error", "always"],
|
|
4122
|
+
"@stylistic/space-before-function-paren": [
|
|
4123
|
+
"error",
|
|
4124
|
+
{
|
|
4125
|
+
anonymous: "always",
|
|
4126
|
+
named: "never",
|
|
4127
|
+
asyncArrow: "always"
|
|
4128
|
+
}
|
|
4129
|
+
],
|
|
4130
|
+
"@stylistic/space-infix-ops": "error",
|
|
4131
|
+
"@stylistic/keyword-spacing": ["error", { before: true, after: true }],
|
|
4132
|
+
"@stylistic/no-extra-parens": ["error", "functions"],
|
|
4133
|
+
"@stylistic/lines-between-class-members": [
|
|
4134
|
+
"error",
|
|
4135
|
+
"always",
|
|
4136
|
+
{ exceptAfterSingleLine: true }
|
|
4137
|
+
],
|
|
4138
|
+
"@stylistic/jsx-quotes": ["error", "prefer-double"],
|
|
4139
|
+
// React
|
|
4022
4140
|
// Enforce new line when declare jsx element e.g. const element = (\newline<div
|
|
4023
|
-
"
|
|
4141
|
+
"@stylistic/jsx-wrap-multilines": [
|
|
4024
4142
|
"warn",
|
|
4025
4143
|
{
|
|
4026
4144
|
declaration: "parens-new-line",
|
|
@@ -4032,30 +4150,21 @@ const react = () => {
|
|
|
4032
4150
|
prop: "parens-new-line"
|
|
4033
4151
|
}
|
|
4034
4152
|
],
|
|
4035
|
-
"
|
|
4153
|
+
"@stylistic/jsx-closing-tag-location": "error",
|
|
4036
4154
|
// Enforce disallow </ div>
|
|
4037
|
-
"
|
|
4038
|
-
"
|
|
4155
|
+
"@stylistic/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
|
|
4156
|
+
"@stylistic/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
|
|
4039
4157
|
// indentLogicalExpressions will fix && element
|
|
4040
|
-
"
|
|
4041
|
-
"
|
|
4158
|
+
"@stylistic/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
|
|
4159
|
+
"@stylistic/jsx-indent-props": ["warn", 2],
|
|
4042
4160
|
// < and > should be on the same line(y-axis) if jsx is multiline
|
|
4043
|
-
"
|
|
4161
|
+
"@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
|
|
4044
4162
|
// Enforce new line when multiline props jsx
|
|
4045
|
-
"
|
|
4046
|
-
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
4047
|
-
"react-refresh/only-export-components": "warn"
|
|
4048
|
-
}
|
|
4049
|
-
},
|
|
4050
|
-
{
|
|
4051
|
-
files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
|
|
4052
|
-
rules: {
|
|
4053
|
-
...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
|
|
4054
|
-
"ssr-friendly/only-export-components": "off"
|
|
4163
|
+
"@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
|
|
4055
4164
|
}
|
|
4056
4165
|
}
|
|
4057
4166
|
];
|
|
4058
|
-
return
|
|
4167
|
+
return configs;
|
|
4059
4168
|
};
|
|
4060
4169
|
|
|
4061
4170
|
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
@@ -4111,49 +4220,6 @@ const typescript = () => {
|
|
|
4111
4220
|
"import/no-named-as-default": "off",
|
|
4112
4221
|
// TS
|
|
4113
4222
|
"no-useless-constructor": "off",
|
|
4114
|
-
indent: "off",
|
|
4115
|
-
// https://github.com/prettier/prettier-eslint/issues/226
|
|
4116
|
-
// JSX indent config in react
|
|
4117
|
-
"@typescript-eslint/indent": ["error", 2, {
|
|
4118
|
-
SwitchCase: 1,
|
|
4119
|
-
VariableDeclarator: 1,
|
|
4120
|
-
outerIIFEBody: 1,
|
|
4121
|
-
MemberExpression: 1,
|
|
4122
|
-
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
4123
|
-
FunctionExpression: { parameters: 1, body: 1 },
|
|
4124
|
-
CallExpression: { arguments: 1 },
|
|
4125
|
-
ArrayExpression: 1,
|
|
4126
|
-
ObjectExpression: 1,
|
|
4127
|
-
ImportDeclaration: 1,
|
|
4128
|
-
flatTernaryExpressions: false,
|
|
4129
|
-
ignoreComments: false,
|
|
4130
|
-
ignoredNodes: [
|
|
4131
|
-
"TemplateLiteral *",
|
|
4132
|
-
"JSXElement",
|
|
4133
|
-
"JSXElement > *",
|
|
4134
|
-
"JSXAttribute",
|
|
4135
|
-
"JSXIdentifier",
|
|
4136
|
-
"JSXNamespacedName",
|
|
4137
|
-
"JSXMemberExpression",
|
|
4138
|
-
"JSXSpreadAttribute",
|
|
4139
|
-
"JSXExpressionContainer",
|
|
4140
|
-
"JSXOpeningElement",
|
|
4141
|
-
"JSXClosingElement",
|
|
4142
|
-
"JSXFragment",
|
|
4143
|
-
"JSXOpeningFragment",
|
|
4144
|
-
"JSXClosingFragment",
|
|
4145
|
-
"JSXText",
|
|
4146
|
-
"JSXEmptyExpression",
|
|
4147
|
-
"JSXSpreadChild",
|
|
4148
|
-
"TSTypeParameterInstantiation",
|
|
4149
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
4150
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
4151
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
4152
|
-
],
|
|
4153
|
-
offsetTernaryExpressions: true
|
|
4154
|
-
}],
|
|
4155
|
-
"@typescript-eslint/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
4156
|
-
"@typescript-eslint/type-annotation-spacing": ["error", {}],
|
|
4157
4223
|
"@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
4158
4224
|
"@typescript-eslint/consistent-type-imports": [
|
|
4159
4225
|
"error",
|
|
@@ -4184,9 +4250,9 @@ const typescript = () => {
|
|
|
4184
4250
|
// required tsconfig.json
|
|
4185
4251
|
// 'etc/no-misused-generics': 'error',
|
|
4186
4252
|
// Overrides JS
|
|
4187
|
-
// no-
|
|
4188
|
-
|
|
4189
|
-
"
|
|
4253
|
+
// original no-undef not compatiable with typescript
|
|
4254
|
+
// refs: https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
4255
|
+
"no-undef": "off",
|
|
4190
4256
|
"no-unused-vars": "off",
|
|
4191
4257
|
"no-redeclare": "off",
|
|
4192
4258
|
"@typescript-eslint/no-redeclare": "error",
|
|
@@ -4197,44 +4263,8 @@ const typescript = () => {
|
|
|
4197
4263
|
"error",
|
|
4198
4264
|
{ functions: false, classes: false, variables: true }
|
|
4199
4265
|
],
|
|
4200
|
-
"brace-style": "off",
|
|
4201
|
-
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
4202
|
-
"@typescript-eslint/brace-style": ["error", "1tbs"],
|
|
4203
|
-
"comma-dangle": "off",
|
|
4204
|
-
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
|
|
4205
|
-
"object-curly-spacing": "off",
|
|
4206
|
-
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
|
4207
|
-
semi: "off",
|
|
4208
|
-
"@typescript-eslint/semi": ["error", "never"],
|
|
4209
|
-
quotes: "off",
|
|
4210
|
-
"@typescript-eslint/quotes": ["error", "single"],
|
|
4211
|
-
"space-before-blocks": "off",
|
|
4212
|
-
"@typescript-eslint/space-before-blocks": ["error", "always"],
|
|
4213
|
-
"space-before-function-paren": "off",
|
|
4214
|
-
"@typescript-eslint/space-before-function-paren": [
|
|
4215
|
-
"error",
|
|
4216
|
-
{
|
|
4217
|
-
anonymous: "always",
|
|
4218
|
-
named: "never",
|
|
4219
|
-
asyncArrow: "always"
|
|
4220
|
-
}
|
|
4221
|
-
],
|
|
4222
|
-
"space-infix-ops": "off",
|
|
4223
|
-
"@typescript-eslint/space-infix-ops": "error",
|
|
4224
|
-
"keyword-spacing": "off",
|
|
4225
|
-
"@typescript-eslint/keyword-spacing": ["error", { before: true, after: true }],
|
|
4226
|
-
"comma-spacing": "off",
|
|
4227
|
-
"@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
|
|
4228
|
-
"no-extra-parens": "off",
|
|
4229
|
-
"@typescript-eslint/no-extra-parens": ["error", "functions"],
|
|
4230
4266
|
"no-loss-of-precision": "off",
|
|
4231
4267
|
"@typescript-eslint/no-loss-of-precision": "error",
|
|
4232
|
-
"lines-between-class-members": "off",
|
|
4233
|
-
"@typescript-eslint/lines-between-class-members": [
|
|
4234
|
-
"error",
|
|
4235
|
-
"always",
|
|
4236
|
-
{ exceptAfterSingleLine: true }
|
|
4237
|
-
],
|
|
4238
4268
|
// off
|
|
4239
4269
|
"@typescript-eslint/camelcase": "off",
|
|
4240
4270
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -4358,10 +4388,11 @@ const presetLangsExtensions = [
|
|
|
4358
4388
|
const presetDefault = [
|
|
4359
4389
|
...presetTypescript,
|
|
4360
4390
|
...react(),
|
|
4391
|
+
...stylistic(),
|
|
4361
4392
|
...presetLangsExtensions,
|
|
4362
4393
|
...progress()
|
|
4363
4394
|
];
|
|
4364
|
-
const aiou = (config = []) => {
|
|
4395
|
+
const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
|
|
4365
4396
|
const configs = [...presetDefault];
|
|
4366
4397
|
if (localPkg.isPackageExists("tailwindcss")) {
|
|
4367
4398
|
configs.push(...tailwindcss());
|
|
@@ -4369,6 +4400,9 @@ const aiou = (config = []) => {
|
|
|
4369
4400
|
if (localPkg.isPackageExists("next")) {
|
|
4370
4401
|
configs.push(...next());
|
|
4371
4402
|
}
|
|
4403
|
+
if (ssr) {
|
|
4404
|
+
configs.push(...ssrReact());
|
|
4405
|
+
}
|
|
4372
4406
|
if (Object.keys(config).length > 0) {
|
|
4373
4407
|
configs.push(...Array.isArray(config) ? config : [config]);
|
|
4374
4408
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import pluginReact from 'eslint-plugin-react';
|
|
|
18
18
|
import pluginReactHooks from 'eslint-plugin-react-hooks';
|
|
19
19
|
import pluginReactRefresh from 'eslint-plugin-react-refresh';
|
|
20
20
|
import pluginSSRFriendly from 'eslint-plugin-ssr-friendly';
|
|
21
|
+
import pluginStylistic from '@stylistic/eslint-plugin';
|
|
21
22
|
import { createRequire } from 'node:module';
|
|
22
23
|
import pluginTypeScript from '@typescript-eslint/eslint-plugin';
|
|
23
24
|
import tsParser from '@typescript-eslint/parser';
|
|
@@ -56,6 +57,7 @@ const GLOB_TEST_DIRS = "**/{test,tests,e2e,__test__,__tests__}/**";
|
|
|
56
57
|
const GLOB_DTS = "**/*.d.ts";
|
|
57
58
|
const GLOB_TS = "**/*.?([cm])ts";
|
|
58
59
|
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
60
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
59
61
|
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
60
62
|
const GLOB_JSON = "**/*.json";
|
|
61
63
|
const GLOB_JSON5 = "**/*.json5";
|
|
@@ -147,7 +149,9 @@ const imports = () => {
|
|
|
147
149
|
{
|
|
148
150
|
files: [
|
|
149
151
|
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
150
|
-
`**/{pages,routes}/**/*.${GLOB_SCRIPT_EXT}`,
|
|
152
|
+
`**/{app,pages,routes}/**/*.${GLOB_SCRIPT_EXT}`,
|
|
153
|
+
`**/App*.${GLOB_SCRIPT_EXT}`,
|
|
154
|
+
`**/Document.${GLOB_SCRIPT_EXT}`,
|
|
151
155
|
"**/{vite,esbuild,rollup,webpack,rspack}.ts",
|
|
152
156
|
GLOB_DTS
|
|
153
157
|
],
|
|
@@ -836,39 +840,21 @@ const javascript = () => {
|
|
|
836
840
|
rules: {
|
|
837
841
|
...pluginStandard.rules,
|
|
838
842
|
...pluginRegexp.configs.recommended.rules,
|
|
839
|
-
// Common
|
|
840
|
-
semi: ["error", "never"],
|
|
841
|
-
// Always need {}
|
|
842
843
|
curly: ["error", "all"],
|
|
843
|
-
quotes: ["error", "single"],
|
|
844
|
-
"quote-props": ["error", "as-needed"],
|
|
845
844
|
"no-unused-vars": "warn",
|
|
846
845
|
"no-param-reassign": "off",
|
|
847
|
-
"array-bracket-spacing": ["error", "never"],
|
|
848
|
-
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
849
|
-
"brace-style": ["error", "1tbs"],
|
|
850
|
-
"block-spacing": ["error", "always"],
|
|
851
846
|
camelcase: "off",
|
|
852
|
-
"comma-spacing": ["error", { before: false, after: true }],
|
|
853
|
-
"comma-style": ["error", "last"],
|
|
854
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
855
847
|
"no-constant-condition": "warn",
|
|
856
848
|
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
857
849
|
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
858
850
|
"no-cond-assign": ["error", "always"],
|
|
859
|
-
"func-call-spacing": ["off", "never"],
|
|
860
|
-
"key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
861
|
-
// https://github.com/prettier/prettier-eslint/issues/226
|
|
862
|
-
indent: ["error", 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
|
|
863
851
|
"no-restricted-syntax": [
|
|
864
852
|
"error",
|
|
865
853
|
"DebuggerStatement",
|
|
866
854
|
"LabeledStatement",
|
|
867
855
|
"WithStatement"
|
|
868
856
|
],
|
|
869
|
-
"object-curly-spacing": ["error", "always"],
|
|
870
857
|
"no-return-await": "off",
|
|
871
|
-
"space-before-function-paren": ["error", "never"],
|
|
872
858
|
// es6
|
|
873
859
|
"no-var": "error",
|
|
874
860
|
"prefer-const": [
|
|
@@ -897,9 +883,7 @@ const javascript = () => {
|
|
|
897
883
|
"prefer-rest-params": "error",
|
|
898
884
|
"prefer-spread": "error",
|
|
899
885
|
"prefer-template": "error",
|
|
900
|
-
"template-curly-spacing": "error",
|
|
901
886
|
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
902
|
-
"generator-star-spacing": "off",
|
|
903
887
|
// best-practice
|
|
904
888
|
"array-callback-return": "error",
|
|
905
889
|
"block-scoped-var": "error",
|
|
@@ -908,15 +892,13 @@ const javascript = () => {
|
|
|
908
892
|
eqeqeq: ["error", "allow-null"],
|
|
909
893
|
"no-alert": "warn",
|
|
910
894
|
"no-case-declarations": "error",
|
|
911
|
-
"no-multi-spaces": "error",
|
|
912
895
|
"no-multi-str": "error",
|
|
913
896
|
"no-with": "error",
|
|
914
897
|
"no-void": "error",
|
|
915
898
|
"no-useless-escape": "off",
|
|
916
899
|
"vars-on-top": "error",
|
|
917
900
|
"require-await": "off",
|
|
918
|
-
"no-return-assign": "off"
|
|
919
|
-
"operator-linebreak": ["error", "before"]
|
|
901
|
+
"no-return-assign": "off"
|
|
920
902
|
}
|
|
921
903
|
}
|
|
922
904
|
];
|
|
@@ -1187,7 +1169,6 @@ const markdown = () => {
|
|
|
1187
1169
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1188
1170
|
"@typescript-eslint/no-use-before-define": "off",
|
|
1189
1171
|
"@typescript-eslint/no-var-requires": "off",
|
|
1190
|
-
"@typescript-eslint/comma-dangle": "off",
|
|
1191
1172
|
"@typescript-eslint/consistent-type-imports": "off",
|
|
1192
1173
|
"@typescript-eslint/no-namespace": "off",
|
|
1193
1174
|
"@typescript-eslint/no-require-imports": "off",
|
|
@@ -4004,21 +3985,158 @@ const react = () => {
|
|
|
4004
3985
|
plugins: {
|
|
4005
3986
|
react: pluginReact,
|
|
4006
3987
|
"react-hooks": pluginReactHooks,
|
|
4007
|
-
"ssr-friendly": pluginSSRFriendly,
|
|
4008
3988
|
"react-refresh": pluginReactRefresh
|
|
4009
3989
|
},
|
|
4010
3990
|
rules: {
|
|
4011
3991
|
...pluginReact.configs.recommended.rules,
|
|
4012
3992
|
...pluginReact.configs["jsx-runtime"].rules,
|
|
4013
3993
|
...pluginReactHooks.configs.recommended.rules,
|
|
4014
|
-
...pluginSSRFriendly.configs.recommended.rules,
|
|
4015
|
-
"jsx-quotes": ["error", "prefer-double"],
|
|
4016
3994
|
"react/prop-types": "off",
|
|
4017
3995
|
"react/no-unescaped-entities": "off",
|
|
4018
3996
|
"react/no-unknown-property": "off",
|
|
4019
3997
|
"react/jsx-boolean-value": ["error", "always"],
|
|
3998
|
+
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
3999
|
+
"react-refresh/only-export-components": "warn"
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
];
|
|
4003
|
+
return config;
|
|
4004
|
+
};
|
|
4005
|
+
const ssrReact = () => {
|
|
4006
|
+
const config = [
|
|
4007
|
+
{
|
|
4008
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
4009
|
+
languageOptions: {
|
|
4010
|
+
parserOptions: {
|
|
4011
|
+
...pluginReact.configs.recommended.parserOptions,
|
|
4012
|
+
...pluginReact.configs["jsx-runtime"].parserOptions
|
|
4013
|
+
}
|
|
4014
|
+
},
|
|
4015
|
+
settings: {
|
|
4016
|
+
react: {
|
|
4017
|
+
// 'detect' will throw warn on monorepo
|
|
4018
|
+
version: "18.0"
|
|
4019
|
+
}
|
|
4020
|
+
},
|
|
4021
|
+
plugins: {
|
|
4022
|
+
"ssr-friendly": pluginSSRFriendly
|
|
4023
|
+
},
|
|
4024
|
+
rules: {
|
|
4025
|
+
...pluginSSRFriendly.configs.recommended.rules
|
|
4026
|
+
}
|
|
4027
|
+
},
|
|
4028
|
+
{
|
|
4029
|
+
files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
|
|
4030
|
+
rules: {
|
|
4031
|
+
...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
|
|
4032
|
+
"ssr-friendly/only-export-components": "off"
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
];
|
|
4036
|
+
return config;
|
|
4037
|
+
};
|
|
4038
|
+
|
|
4039
|
+
const stylistic = () => {
|
|
4040
|
+
const config = pluginStylistic.configs.customize({
|
|
4041
|
+
flat: true,
|
|
4042
|
+
indent: 2,
|
|
4043
|
+
jsx: true,
|
|
4044
|
+
quotes: "single",
|
|
4045
|
+
semi: false
|
|
4046
|
+
});
|
|
4047
|
+
const off = {};
|
|
4048
|
+
Object.keys(config.rules).forEach((key) => {
|
|
4049
|
+
off[key.replace("@stylistic/", "")] = "off";
|
|
4050
|
+
});
|
|
4051
|
+
const configs = [
|
|
4052
|
+
{
|
|
4053
|
+
files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
|
|
4054
|
+
plugins: {
|
|
4055
|
+
...config.plugins
|
|
4056
|
+
},
|
|
4057
|
+
rules: {
|
|
4058
|
+
...off,
|
|
4059
|
+
...config.rules,
|
|
4060
|
+
"@stylistic/quotes": ["error", "single"],
|
|
4061
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
4062
|
+
"@stylistic/array-bracket-spacing": ["error", "never"],
|
|
4063
|
+
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
4064
|
+
"@stylistic/brace-style": ["error", "1tbs"],
|
|
4065
|
+
"@stylistic/block-spacing": ["error", "always"],
|
|
4066
|
+
"@stylistic/comma-spacing": ["error", { before: false, after: true }],
|
|
4067
|
+
"@stylistic/comma-style": ["error", "last"],
|
|
4068
|
+
"comma-dangle": "off",
|
|
4069
|
+
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
|
4070
|
+
"@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
4071
|
+
"@stylistic/indent": ["error", 2, {
|
|
4072
|
+
SwitchCase: 1,
|
|
4073
|
+
VariableDeclarator: 1,
|
|
4074
|
+
outerIIFEBody: 1,
|
|
4075
|
+
MemberExpression: 1,
|
|
4076
|
+
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
4077
|
+
FunctionExpression: { parameters: 1, body: 1 },
|
|
4078
|
+
CallExpression: { arguments: 1 },
|
|
4079
|
+
ArrayExpression: 1,
|
|
4080
|
+
ObjectExpression: 1,
|
|
4081
|
+
ImportDeclaration: 1,
|
|
4082
|
+
flatTernaryExpressions: false,
|
|
4083
|
+
ignoreComments: false,
|
|
4084
|
+
ignoredNodes: [
|
|
4085
|
+
"TemplateLiteral *",
|
|
4086
|
+
"JSXElement",
|
|
4087
|
+
"JSXElement > *",
|
|
4088
|
+
"JSXAttribute",
|
|
4089
|
+
"JSXIdentifier",
|
|
4090
|
+
"JSXNamespacedName",
|
|
4091
|
+
"JSXMemberExpression",
|
|
4092
|
+
"JSXSpreadAttribute",
|
|
4093
|
+
"JSXExpressionContainer",
|
|
4094
|
+
"JSXOpeningElement",
|
|
4095
|
+
"JSXClosingElement",
|
|
4096
|
+
"JSXFragment",
|
|
4097
|
+
"JSXOpeningFragment",
|
|
4098
|
+
"JSXClosingFragment",
|
|
4099
|
+
"JSXText",
|
|
4100
|
+
"JSXEmptyExpression",
|
|
4101
|
+
"JSXSpreadChild",
|
|
4102
|
+
"TSTypeParameterInstantiation",
|
|
4103
|
+
"FunctionExpression > .params[decorators.length > 0]",
|
|
4104
|
+
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
4105
|
+
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
4106
|
+
],
|
|
4107
|
+
offsetTernaryExpressions: true
|
|
4108
|
+
}],
|
|
4109
|
+
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
4110
|
+
"@stylistic/template-curly-spacing": "error",
|
|
4111
|
+
"@stylistic/generator-star-spacing": "off",
|
|
4112
|
+
"@stylistic/no-multi-spaces": "error",
|
|
4113
|
+
"@stylistic/operator-linebreak": ["error", "before"],
|
|
4114
|
+
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
4115
|
+
"@stylistic/type-annotation-spacing": ["error", {}],
|
|
4116
|
+
// no-spaced-func alert -- https://eslint.org/docs/latest/rules/no-spaced-func
|
|
4117
|
+
"@stylistic/func-call-spacing": ["error", "never"],
|
|
4118
|
+
"@stylistic/semi": ["error", "never"],
|
|
4119
|
+
"@stylistic/space-before-blocks": ["error", "always"],
|
|
4120
|
+
"@stylistic/space-before-function-paren": [
|
|
4121
|
+
"error",
|
|
4122
|
+
{
|
|
4123
|
+
anonymous: "always",
|
|
4124
|
+
named: "never",
|
|
4125
|
+
asyncArrow: "always"
|
|
4126
|
+
}
|
|
4127
|
+
],
|
|
4128
|
+
"@stylistic/space-infix-ops": "error",
|
|
4129
|
+
"@stylistic/keyword-spacing": ["error", { before: true, after: true }],
|
|
4130
|
+
"@stylistic/no-extra-parens": ["error", "functions"],
|
|
4131
|
+
"@stylistic/lines-between-class-members": [
|
|
4132
|
+
"error",
|
|
4133
|
+
"always",
|
|
4134
|
+
{ exceptAfterSingleLine: true }
|
|
4135
|
+
],
|
|
4136
|
+
"@stylistic/jsx-quotes": ["error", "prefer-double"],
|
|
4137
|
+
// React
|
|
4020
4138
|
// Enforce new line when declare jsx element e.g. const element = (\newline<div
|
|
4021
|
-
"
|
|
4139
|
+
"@stylistic/jsx-wrap-multilines": [
|
|
4022
4140
|
"warn",
|
|
4023
4141
|
{
|
|
4024
4142
|
declaration: "parens-new-line",
|
|
@@ -4030,30 +4148,21 @@ const react = () => {
|
|
|
4030
4148
|
prop: "parens-new-line"
|
|
4031
4149
|
}
|
|
4032
4150
|
],
|
|
4033
|
-
"
|
|
4151
|
+
"@stylistic/jsx-closing-tag-location": "error",
|
|
4034
4152
|
// Enforce disallow </ div>
|
|
4035
|
-
"
|
|
4036
|
-
"
|
|
4153
|
+
"@stylistic/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
|
|
4154
|
+
"@stylistic/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
|
|
4037
4155
|
// indentLogicalExpressions will fix && element
|
|
4038
|
-
"
|
|
4039
|
-
"
|
|
4156
|
+
"@stylistic/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
|
|
4157
|
+
"@stylistic/jsx-indent-props": ["warn", 2],
|
|
4040
4158
|
// < and > should be on the same line(y-axis) if jsx is multiline
|
|
4041
|
-
"
|
|
4159
|
+
"@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
|
|
4042
4160
|
// Enforce new line when multiline props jsx
|
|
4043
|
-
"
|
|
4044
|
-
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
4045
|
-
"react-refresh/only-export-components": "warn"
|
|
4046
|
-
}
|
|
4047
|
-
},
|
|
4048
|
-
{
|
|
4049
|
-
files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
|
|
4050
|
-
rules: {
|
|
4051
|
-
...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
|
|
4052
|
-
"ssr-friendly/only-export-components": "off"
|
|
4161
|
+
"@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
|
|
4053
4162
|
}
|
|
4054
4163
|
}
|
|
4055
4164
|
];
|
|
4056
|
-
return
|
|
4165
|
+
return configs;
|
|
4057
4166
|
};
|
|
4058
4167
|
|
|
4059
4168
|
const require = createRequire(import.meta.url);
|
|
@@ -4109,49 +4218,6 @@ const typescript = () => {
|
|
|
4109
4218
|
"import/no-named-as-default": "off",
|
|
4110
4219
|
// TS
|
|
4111
4220
|
"no-useless-constructor": "off",
|
|
4112
|
-
indent: "off",
|
|
4113
|
-
// https://github.com/prettier/prettier-eslint/issues/226
|
|
4114
|
-
// JSX indent config in react
|
|
4115
|
-
"@typescript-eslint/indent": ["error", 2, {
|
|
4116
|
-
SwitchCase: 1,
|
|
4117
|
-
VariableDeclarator: 1,
|
|
4118
|
-
outerIIFEBody: 1,
|
|
4119
|
-
MemberExpression: 1,
|
|
4120
|
-
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
4121
|
-
FunctionExpression: { parameters: 1, body: 1 },
|
|
4122
|
-
CallExpression: { arguments: 1 },
|
|
4123
|
-
ArrayExpression: 1,
|
|
4124
|
-
ObjectExpression: 1,
|
|
4125
|
-
ImportDeclaration: 1,
|
|
4126
|
-
flatTernaryExpressions: false,
|
|
4127
|
-
ignoreComments: false,
|
|
4128
|
-
ignoredNodes: [
|
|
4129
|
-
"TemplateLiteral *",
|
|
4130
|
-
"JSXElement",
|
|
4131
|
-
"JSXElement > *",
|
|
4132
|
-
"JSXAttribute",
|
|
4133
|
-
"JSXIdentifier",
|
|
4134
|
-
"JSXNamespacedName",
|
|
4135
|
-
"JSXMemberExpression",
|
|
4136
|
-
"JSXSpreadAttribute",
|
|
4137
|
-
"JSXExpressionContainer",
|
|
4138
|
-
"JSXOpeningElement",
|
|
4139
|
-
"JSXClosingElement",
|
|
4140
|
-
"JSXFragment",
|
|
4141
|
-
"JSXOpeningFragment",
|
|
4142
|
-
"JSXClosingFragment",
|
|
4143
|
-
"JSXText",
|
|
4144
|
-
"JSXEmptyExpression",
|
|
4145
|
-
"JSXSpreadChild",
|
|
4146
|
-
"TSTypeParameterInstantiation",
|
|
4147
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
4148
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
4149
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
4150
|
-
],
|
|
4151
|
-
offsetTernaryExpressions: true
|
|
4152
|
-
}],
|
|
4153
|
-
"@typescript-eslint/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
4154
|
-
"@typescript-eslint/type-annotation-spacing": ["error", {}],
|
|
4155
4221
|
"@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
4156
4222
|
"@typescript-eslint/consistent-type-imports": [
|
|
4157
4223
|
"error",
|
|
@@ -4182,9 +4248,9 @@ const typescript = () => {
|
|
|
4182
4248
|
// required tsconfig.json
|
|
4183
4249
|
// 'etc/no-misused-generics': 'error',
|
|
4184
4250
|
// Overrides JS
|
|
4185
|
-
// no-
|
|
4186
|
-
|
|
4187
|
-
"
|
|
4251
|
+
// original no-undef not compatiable with typescript
|
|
4252
|
+
// refs: https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
4253
|
+
"no-undef": "off",
|
|
4188
4254
|
"no-unused-vars": "off",
|
|
4189
4255
|
"no-redeclare": "off",
|
|
4190
4256
|
"@typescript-eslint/no-redeclare": "error",
|
|
@@ -4195,44 +4261,8 @@ const typescript = () => {
|
|
|
4195
4261
|
"error",
|
|
4196
4262
|
{ functions: false, classes: false, variables: true }
|
|
4197
4263
|
],
|
|
4198
|
-
"brace-style": "off",
|
|
4199
|
-
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
4200
|
-
"@typescript-eslint/brace-style": ["error", "1tbs"],
|
|
4201
|
-
"comma-dangle": "off",
|
|
4202
|
-
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
|
|
4203
|
-
"object-curly-spacing": "off",
|
|
4204
|
-
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
|
4205
|
-
semi: "off",
|
|
4206
|
-
"@typescript-eslint/semi": ["error", "never"],
|
|
4207
|
-
quotes: "off",
|
|
4208
|
-
"@typescript-eslint/quotes": ["error", "single"],
|
|
4209
|
-
"space-before-blocks": "off",
|
|
4210
|
-
"@typescript-eslint/space-before-blocks": ["error", "always"],
|
|
4211
|
-
"space-before-function-paren": "off",
|
|
4212
|
-
"@typescript-eslint/space-before-function-paren": [
|
|
4213
|
-
"error",
|
|
4214
|
-
{
|
|
4215
|
-
anonymous: "always",
|
|
4216
|
-
named: "never",
|
|
4217
|
-
asyncArrow: "always"
|
|
4218
|
-
}
|
|
4219
|
-
],
|
|
4220
|
-
"space-infix-ops": "off",
|
|
4221
|
-
"@typescript-eslint/space-infix-ops": "error",
|
|
4222
|
-
"keyword-spacing": "off",
|
|
4223
|
-
"@typescript-eslint/keyword-spacing": ["error", { before: true, after: true }],
|
|
4224
|
-
"comma-spacing": "off",
|
|
4225
|
-
"@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
|
|
4226
|
-
"no-extra-parens": "off",
|
|
4227
|
-
"@typescript-eslint/no-extra-parens": ["error", "functions"],
|
|
4228
4264
|
"no-loss-of-precision": "off",
|
|
4229
4265
|
"@typescript-eslint/no-loss-of-precision": "error",
|
|
4230
|
-
"lines-between-class-members": "off",
|
|
4231
|
-
"@typescript-eslint/lines-between-class-members": [
|
|
4232
|
-
"error",
|
|
4233
|
-
"always",
|
|
4234
|
-
{ exceptAfterSingleLine: true }
|
|
4235
|
-
],
|
|
4236
4266
|
// off
|
|
4237
4267
|
"@typescript-eslint/camelcase": "off",
|
|
4238
4268
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -4356,10 +4386,11 @@ const presetLangsExtensions = [
|
|
|
4356
4386
|
const presetDefault = [
|
|
4357
4387
|
...presetTypescript,
|
|
4358
4388
|
...react(),
|
|
4389
|
+
...stylistic(),
|
|
4359
4390
|
...presetLangsExtensions,
|
|
4360
4391
|
...progress()
|
|
4361
4392
|
];
|
|
4362
|
-
const aiou = (config = []) => {
|
|
4393
|
+
const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
|
|
4363
4394
|
const configs = [...presetDefault];
|
|
4364
4395
|
if (isPackageExists("tailwindcss")) {
|
|
4365
4396
|
configs.push(...tailwindcss());
|
|
@@ -4367,6 +4398,9 @@ const aiou = (config = []) => {
|
|
|
4367
4398
|
if (isPackageExists("next")) {
|
|
4368
4399
|
configs.push(...next());
|
|
4369
4400
|
}
|
|
4401
|
+
if (ssr) {
|
|
4402
|
+
configs.push(...ssrReact());
|
|
4403
|
+
}
|
|
4370
4404
|
if (Object.keys(config).length > 0) {
|
|
4371
4405
|
configs.push(...Array.isArray(config) ? config : [config]);
|
|
4372
4406
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const comments: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const comments: () => FlatESLintConfig[];
|
package/dts/configs/ignores.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const ignores: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const ignores: () => FlatESLintConfig[];
|
package/dts/configs/imports.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const imports: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const imports: () => FlatESLintConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const javascript: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const javascript: () => FlatESLintConfig[];
|
package/dts/configs/jsonc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const jsonc: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const jsonc: () => FlatESLintConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const markdown: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const markdown: () => FlatESLintConfig[];
|
package/dts/configs/next.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const next: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const next: () => FlatESLintConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const progress: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const progress: () => FlatESLintConfig[];
|
package/dts/configs/react.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const react: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const react: () => FlatESLintConfig[];
|
|
3
|
+
export declare const ssrReact: () => FlatESLintConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const tailwindcss: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const tailwindcss: () => FlatESLintConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const typescript: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const typescript: () => FlatESLintConfig[];
|
package/dts/configs/unicorn.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const unicorn: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const unicorn: () => FlatESLintConfig[];
|
package/dts/configs/yml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const yml: () =>
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
export declare const yml: () => FlatESLintConfig[];
|
package/dts/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { FlatESLintConfig } from 'eslint-define-config';
|
|
2
|
+
interface Options {
|
|
3
|
+
ssr?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const aiou: ({ ssr }?: Options, config?: FlatESLintConfig | FlatESLintConfig[]) => FlatESLintConfig[];
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiou/eslint-config",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "eslint config for aiou template",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"eslint": ">=7.4.0 || ^8"
|
|
29
|
+
"eslint": ">=7.4.0 || ^8.53.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@next/eslint-plugin-next": "^13.1.4",
|
|
33
|
+
"@stylistic/eslint-plugin": "^1.4.1",
|
|
33
34
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
34
35
|
"@typescript-eslint/parser": "^6.9.0",
|
|
35
|
-
"eslint-define-config": "^
|
|
36
|
+
"eslint-define-config": "^2.0.0",
|
|
36
37
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
37
38
|
"eslint-plugin-etc": "^2.0.3",
|
|
38
39
|
"eslint-plugin-i": "^2.28.1",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"jsonc-eslint-parser": "^2.4.0",
|
|
56
57
|
"local-pkg": "^0.4.3",
|
|
57
58
|
"yaml-eslint-parser": "^1.2.2",
|
|
58
|
-
"@aiou/eslint-ignore": "0.5.
|
|
59
|
+
"@aiou/eslint-ignore": "0.5.1",
|
|
59
60
|
"@aiou/eslint-plugin-progress": "0.3.1"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|