@aiou/eslint-config 1.0.6 → 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 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";
@@ -840,39 +842,21 @@ const javascript = () => {
840
842
  rules: {
841
843
  ...pluginStandard.rules,
842
844
  ...pluginRegexp.configs.recommended.rules,
843
- // Common
844
- semi: ["error", "never"],
845
- // Always need {}
846
845
  curly: ["error", "all"],
847
- quotes: ["error", "single"],
848
- "quote-props": ["error", "as-needed"],
849
846
  "no-unused-vars": "warn",
850
847
  "no-param-reassign": "off",
851
- "array-bracket-spacing": ["error", "never"],
852
- // https://eslint.org/docs/latest/rules/brace-style#1tbs
853
- "brace-style": ["error", "1tbs"],
854
- "block-spacing": ["error", "always"],
855
848
  camelcase: "off",
856
- "comma-spacing": ["error", { before: false, after: true }],
857
- "comma-style": ["error", "last"],
858
- "comma-dangle": ["error", "always-multiline"],
859
849
  "no-constant-condition": "warn",
860
850
  "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
861
851
  "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
862
852
  "no-cond-assign": ["error", "always"],
863
- "func-call-spacing": ["off", "never"],
864
- "key-spacing": ["error", { beforeColon: false, afterColon: true }],
865
- // https://github.com/prettier/prettier-eslint/issues/226
866
- indent: ["error", 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
867
853
  "no-restricted-syntax": [
868
854
  "error",
869
855
  "DebuggerStatement",
870
856
  "LabeledStatement",
871
857
  "WithStatement"
872
858
  ],
873
- "object-curly-spacing": ["error", "always"],
874
859
  "no-return-await": "off",
875
- "space-before-function-paren": ["error", "never"],
876
860
  // es6
877
861
  "no-var": "error",
878
862
  "prefer-const": [
@@ -901,9 +885,7 @@ const javascript = () => {
901
885
  "prefer-rest-params": "error",
902
886
  "prefer-spread": "error",
903
887
  "prefer-template": "error",
904
- "template-curly-spacing": "error",
905
888
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
906
- "generator-star-spacing": "off",
907
889
  // best-practice
908
890
  "array-callback-return": "error",
909
891
  "block-scoped-var": "error",
@@ -912,15 +894,13 @@ const javascript = () => {
912
894
  eqeqeq: ["error", "allow-null"],
913
895
  "no-alert": "warn",
914
896
  "no-case-declarations": "error",
915
- "no-multi-spaces": "error",
916
897
  "no-multi-str": "error",
917
898
  "no-with": "error",
918
899
  "no-void": "error",
919
900
  "no-useless-escape": "off",
920
901
  "vars-on-top": "error",
921
902
  "require-await": "off",
922
- "no-return-assign": "off",
923
- "operator-linebreak": ["error", "before"]
903
+ "no-return-assign": "off"
924
904
  }
925
905
  }
926
906
  ];
@@ -1191,7 +1171,6 @@ const markdown = () => {
1191
1171
  "@typescript-eslint/no-unused-vars": "off",
1192
1172
  "@typescript-eslint/no-use-before-define": "off",
1193
1173
  "@typescript-eslint/no-var-requires": "off",
1194
- "@typescript-eslint/comma-dangle": "off",
1195
1174
  "@typescript-eslint/consistent-type-imports": "off",
1196
1175
  "@typescript-eslint/no-namespace": "off",
1197
1176
  "@typescript-eslint/no-require-imports": "off",
@@ -4008,21 +3987,158 @@ const react = () => {
4008
3987
  plugins: {
4009
3988
  react: pluginReact,
4010
3989
  "react-hooks": pluginReactHooks,
4011
- "ssr-friendly": pluginSSRFriendly,
4012
3990
  "react-refresh": pluginReactRefresh
4013
3991
  },
4014
3992
  rules: {
4015
3993
  ...pluginReact.configs.recommended.rules,
4016
3994
  ...pluginReact.configs["jsx-runtime"].rules,
4017
3995
  ...pluginReactHooks.configs.recommended.rules,
4018
- ...pluginSSRFriendly.configs.recommended.rules,
4019
- "jsx-quotes": ["error", "prefer-double"],
4020
3996
  "react/prop-types": "off",
4021
3997
  "react/no-unescaped-entities": "off",
4022
3998
  "react/no-unknown-property": "off",
4023
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
4024
4140
  // Enforce new line when declare jsx element e.g. const element = (\newline<div
4025
- "react/jsx-wrap-multilines": [
4141
+ "@stylistic/jsx-wrap-multilines": [
4026
4142
  "warn",
4027
4143
  {
4028
4144
  declaration: "parens-new-line",
@@ -4034,30 +4150,21 @@ const react = () => {
4034
4150
  prop: "parens-new-line"
4035
4151
  }
4036
4152
  ],
4037
- "react/jsx-closing-tag-location": "error",
4153
+ "@stylistic/jsx-closing-tag-location": "error",
4038
4154
  // Enforce disallow </ div>
4039
- "react/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
4040
- "react/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
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" }],
4041
4157
  // indentLogicalExpressions will fix && element
4042
- "react/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
4043
- "react/jsx-indent-props": ["warn", 2],
4158
+ "@stylistic/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
4159
+ "@stylistic/jsx-indent-props": ["warn", 2],
4044
4160
  // < and > should be on the same line(y-axis) if jsx is multiline
4045
- "react/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4161
+ "@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4046
4162
  // Enforce new line when multiline props jsx
4047
- "react/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
4048
- // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
4049
- "react-refresh/only-export-components": "warn"
4050
- }
4051
- },
4052
- {
4053
- files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
4054
- rules: {
4055
- ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
4056
- "ssr-friendly/only-export-components": "off"
4163
+ "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
4057
4164
  }
4058
4165
  }
4059
4166
  ];
4060
- return config;
4167
+ return configs;
4061
4168
  };
4062
4169
 
4063
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)));
@@ -4113,49 +4220,6 @@ const typescript = () => {
4113
4220
  "import/no-named-as-default": "off",
4114
4221
  // TS
4115
4222
  "no-useless-constructor": "off",
4116
- indent: "off",
4117
- // https://github.com/prettier/prettier-eslint/issues/226
4118
- // JSX indent config in react
4119
- "@typescript-eslint/indent": ["error", 2, {
4120
- SwitchCase: 1,
4121
- VariableDeclarator: 1,
4122
- outerIIFEBody: 1,
4123
- MemberExpression: 1,
4124
- FunctionDeclaration: { parameters: 1, body: 1 },
4125
- FunctionExpression: { parameters: 1, body: 1 },
4126
- CallExpression: { arguments: 1 },
4127
- ArrayExpression: 1,
4128
- ObjectExpression: 1,
4129
- ImportDeclaration: 1,
4130
- flatTernaryExpressions: false,
4131
- ignoreComments: false,
4132
- ignoredNodes: [
4133
- "TemplateLiteral *",
4134
- "JSXElement",
4135
- "JSXElement > *",
4136
- "JSXAttribute",
4137
- "JSXIdentifier",
4138
- "JSXNamespacedName",
4139
- "JSXMemberExpression",
4140
- "JSXSpreadAttribute",
4141
- "JSXExpressionContainer",
4142
- "JSXOpeningElement",
4143
- "JSXClosingElement",
4144
- "JSXFragment",
4145
- "JSXOpeningFragment",
4146
- "JSXClosingFragment",
4147
- "JSXText",
4148
- "JSXEmptyExpression",
4149
- "JSXSpreadChild",
4150
- "TSTypeParameterInstantiation",
4151
- "FunctionExpression > .params[decorators.length > 0]",
4152
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
4153
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
4154
- ],
4155
- offsetTernaryExpressions: true
4156
- }],
4157
- "@typescript-eslint/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
4158
- "@typescript-eslint/type-annotation-spacing": ["error", {}],
4159
4223
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
4160
4224
  "@typescript-eslint/consistent-type-imports": [
4161
4225
  "error",
@@ -4189,9 +4253,6 @@ const typescript = () => {
4189
4253
  // original no-undef not compatiable with typescript
4190
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
4191
4255
  "no-undef": "off",
4192
- // no-spaced-func alert -- https://eslint.org/docs/latest/rules/no-spaced-func
4193
- "func-call-spacing": "off",
4194
- "@typescript-eslint/func-call-spacing": ["error", "never"],
4195
4256
  "no-unused-vars": "off",
4196
4257
  "no-redeclare": "off",
4197
4258
  "@typescript-eslint/no-redeclare": "error",
@@ -4202,44 +4263,8 @@ const typescript = () => {
4202
4263
  "error",
4203
4264
  { functions: false, classes: false, variables: true }
4204
4265
  ],
4205
- "brace-style": "off",
4206
- // https://eslint.org/docs/latest/rules/brace-style#1tbs
4207
- "@typescript-eslint/brace-style": ["error", "1tbs"],
4208
- "comma-dangle": "off",
4209
- "@typescript-eslint/comma-dangle": ["error", "always-multiline"],
4210
- "object-curly-spacing": "off",
4211
- "@typescript-eslint/object-curly-spacing": ["error", "always"],
4212
- semi: "off",
4213
- "@typescript-eslint/semi": ["error", "never"],
4214
- quotes: "off",
4215
- "@typescript-eslint/quotes": ["error", "single"],
4216
- "space-before-blocks": "off",
4217
- "@typescript-eslint/space-before-blocks": ["error", "always"],
4218
- "space-before-function-paren": "off",
4219
- "@typescript-eslint/space-before-function-paren": [
4220
- "error",
4221
- {
4222
- anonymous: "always",
4223
- named: "never",
4224
- asyncArrow: "always"
4225
- }
4226
- ],
4227
- "space-infix-ops": "off",
4228
- "@typescript-eslint/space-infix-ops": "error",
4229
- "keyword-spacing": "off",
4230
- "@typescript-eslint/keyword-spacing": ["error", { before: true, after: true }],
4231
- "comma-spacing": "off",
4232
- "@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
4233
- "no-extra-parens": "off",
4234
- "@typescript-eslint/no-extra-parens": ["error", "functions"],
4235
4266
  "no-loss-of-precision": "off",
4236
4267
  "@typescript-eslint/no-loss-of-precision": "error",
4237
- "lines-between-class-members": "off",
4238
- "@typescript-eslint/lines-between-class-members": [
4239
- "error",
4240
- "always",
4241
- { exceptAfterSingleLine: true }
4242
- ],
4243
4268
  // off
4244
4269
  "@typescript-eslint/camelcase": "off",
4245
4270
  "@typescript-eslint/explicit-function-return-type": "off",
@@ -4363,10 +4388,11 @@ const presetLangsExtensions = [
4363
4388
  const presetDefault = [
4364
4389
  ...presetTypescript,
4365
4390
  ...react(),
4391
+ ...stylistic(),
4366
4392
  ...presetLangsExtensions,
4367
4393
  ...progress()
4368
4394
  ];
4369
- const aiou = (config = []) => {
4395
+ const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4370
4396
  const configs = [...presetDefault];
4371
4397
  if (localPkg.isPackageExists("tailwindcss")) {
4372
4398
  configs.push(...tailwindcss());
@@ -4374,6 +4400,9 @@ const aiou = (config = []) => {
4374
4400
  if (localPkg.isPackageExists("next")) {
4375
4401
  configs.push(...next());
4376
4402
  }
4403
+ if (ssr) {
4404
+ configs.push(...ssrReact());
4405
+ }
4377
4406
  if (Object.keys(config).length > 0) {
4378
4407
  configs.push(...Array.isArray(config) ? config : [config]);
4379
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";
@@ -838,39 +840,21 @@ const javascript = () => {
838
840
  rules: {
839
841
  ...pluginStandard.rules,
840
842
  ...pluginRegexp.configs.recommended.rules,
841
- // Common
842
- semi: ["error", "never"],
843
- // Always need {}
844
843
  curly: ["error", "all"],
845
- quotes: ["error", "single"],
846
- "quote-props": ["error", "as-needed"],
847
844
  "no-unused-vars": "warn",
848
845
  "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
846
  camelcase: "off",
854
- "comma-spacing": ["error", { before: false, after: true }],
855
- "comma-style": ["error", "last"],
856
- "comma-dangle": ["error", "always-multiline"],
857
847
  "no-constant-condition": "warn",
858
848
  "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
859
849
  "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
860
850
  "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
851
  "no-restricted-syntax": [
866
852
  "error",
867
853
  "DebuggerStatement",
868
854
  "LabeledStatement",
869
855
  "WithStatement"
870
856
  ],
871
- "object-curly-spacing": ["error", "always"],
872
857
  "no-return-await": "off",
873
- "space-before-function-paren": ["error", "never"],
874
858
  // es6
875
859
  "no-var": "error",
876
860
  "prefer-const": [
@@ -899,9 +883,7 @@ const javascript = () => {
899
883
  "prefer-rest-params": "error",
900
884
  "prefer-spread": "error",
901
885
  "prefer-template": "error",
902
- "template-curly-spacing": "error",
903
886
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
904
- "generator-star-spacing": "off",
905
887
  // best-practice
906
888
  "array-callback-return": "error",
907
889
  "block-scoped-var": "error",
@@ -910,15 +892,13 @@ const javascript = () => {
910
892
  eqeqeq: ["error", "allow-null"],
911
893
  "no-alert": "warn",
912
894
  "no-case-declarations": "error",
913
- "no-multi-spaces": "error",
914
895
  "no-multi-str": "error",
915
896
  "no-with": "error",
916
897
  "no-void": "error",
917
898
  "no-useless-escape": "off",
918
899
  "vars-on-top": "error",
919
900
  "require-await": "off",
920
- "no-return-assign": "off",
921
- "operator-linebreak": ["error", "before"]
901
+ "no-return-assign": "off"
922
902
  }
923
903
  }
924
904
  ];
@@ -1189,7 +1169,6 @@ const markdown = () => {
1189
1169
  "@typescript-eslint/no-unused-vars": "off",
1190
1170
  "@typescript-eslint/no-use-before-define": "off",
1191
1171
  "@typescript-eslint/no-var-requires": "off",
1192
- "@typescript-eslint/comma-dangle": "off",
1193
1172
  "@typescript-eslint/consistent-type-imports": "off",
1194
1173
  "@typescript-eslint/no-namespace": "off",
1195
1174
  "@typescript-eslint/no-require-imports": "off",
@@ -4006,21 +3985,158 @@ const react = () => {
4006
3985
  plugins: {
4007
3986
  react: pluginReact,
4008
3987
  "react-hooks": pluginReactHooks,
4009
- "ssr-friendly": pluginSSRFriendly,
4010
3988
  "react-refresh": pluginReactRefresh
4011
3989
  },
4012
3990
  rules: {
4013
3991
  ...pluginReact.configs.recommended.rules,
4014
3992
  ...pluginReact.configs["jsx-runtime"].rules,
4015
3993
  ...pluginReactHooks.configs.recommended.rules,
4016
- ...pluginSSRFriendly.configs.recommended.rules,
4017
- "jsx-quotes": ["error", "prefer-double"],
4018
3994
  "react/prop-types": "off",
4019
3995
  "react/no-unescaped-entities": "off",
4020
3996
  "react/no-unknown-property": "off",
4021
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
4022
4138
  // Enforce new line when declare jsx element e.g. const element = (\newline<div
4023
- "react/jsx-wrap-multilines": [
4139
+ "@stylistic/jsx-wrap-multilines": [
4024
4140
  "warn",
4025
4141
  {
4026
4142
  declaration: "parens-new-line",
@@ -4032,30 +4148,21 @@ const react = () => {
4032
4148
  prop: "parens-new-line"
4033
4149
  }
4034
4150
  ],
4035
- "react/jsx-closing-tag-location": "error",
4151
+ "@stylistic/jsx-closing-tag-location": "error",
4036
4152
  // Enforce disallow </ div>
4037
- "react/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
4038
- "react/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
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" }],
4039
4155
  // indentLogicalExpressions will fix && element
4040
- "react/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
4041
- "react/jsx-indent-props": ["warn", 2],
4156
+ "@stylistic/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
4157
+ "@stylistic/jsx-indent-props": ["warn", 2],
4042
4158
  // < and > should be on the same line(y-axis) if jsx is multiline
4043
- "react/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4159
+ "@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4044
4160
  // Enforce new line when multiline props jsx
4045
- "react/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
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"
4161
+ "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
4055
4162
  }
4056
4163
  }
4057
4164
  ];
4058
- return config;
4165
+ return configs;
4059
4166
  };
4060
4167
 
4061
4168
  const require = createRequire(import.meta.url);
@@ -4111,49 +4218,6 @@ const typescript = () => {
4111
4218
  "import/no-named-as-default": "off",
4112
4219
  // TS
4113
4220
  "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
4221
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
4158
4222
  "@typescript-eslint/consistent-type-imports": [
4159
4223
  "error",
@@ -4187,9 +4251,6 @@ const typescript = () => {
4187
4251
  // original no-undef not compatiable with typescript
4188
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
4189
4253
  "no-undef": "off",
4190
- // no-spaced-func alert -- https://eslint.org/docs/latest/rules/no-spaced-func
4191
- "func-call-spacing": "off",
4192
- "@typescript-eslint/func-call-spacing": ["error", "never"],
4193
4254
  "no-unused-vars": "off",
4194
4255
  "no-redeclare": "off",
4195
4256
  "@typescript-eslint/no-redeclare": "error",
@@ -4200,44 +4261,8 @@ const typescript = () => {
4200
4261
  "error",
4201
4262
  { functions: false, classes: false, variables: true }
4202
4263
  ],
4203
- "brace-style": "off",
4204
- // https://eslint.org/docs/latest/rules/brace-style#1tbs
4205
- "@typescript-eslint/brace-style": ["error", "1tbs"],
4206
- "comma-dangle": "off",
4207
- "@typescript-eslint/comma-dangle": ["error", "always-multiline"],
4208
- "object-curly-spacing": "off",
4209
- "@typescript-eslint/object-curly-spacing": ["error", "always"],
4210
- semi: "off",
4211
- "@typescript-eslint/semi": ["error", "never"],
4212
- quotes: "off",
4213
- "@typescript-eslint/quotes": ["error", "single"],
4214
- "space-before-blocks": "off",
4215
- "@typescript-eslint/space-before-blocks": ["error", "always"],
4216
- "space-before-function-paren": "off",
4217
- "@typescript-eslint/space-before-function-paren": [
4218
- "error",
4219
- {
4220
- anonymous: "always",
4221
- named: "never",
4222
- asyncArrow: "always"
4223
- }
4224
- ],
4225
- "space-infix-ops": "off",
4226
- "@typescript-eslint/space-infix-ops": "error",
4227
- "keyword-spacing": "off",
4228
- "@typescript-eslint/keyword-spacing": ["error", { before: true, after: true }],
4229
- "comma-spacing": "off",
4230
- "@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
4231
- "no-extra-parens": "off",
4232
- "@typescript-eslint/no-extra-parens": ["error", "functions"],
4233
4264
  "no-loss-of-precision": "off",
4234
4265
  "@typescript-eslint/no-loss-of-precision": "error",
4235
- "lines-between-class-members": "off",
4236
- "@typescript-eslint/lines-between-class-members": [
4237
- "error",
4238
- "always",
4239
- { exceptAfterSingleLine: true }
4240
- ],
4241
4266
  // off
4242
4267
  "@typescript-eslint/camelcase": "off",
4243
4268
  "@typescript-eslint/explicit-function-return-type": "off",
@@ -4361,10 +4386,11 @@ const presetLangsExtensions = [
4361
4386
  const presetDefault = [
4362
4387
  ...presetTypescript,
4363
4388
  ...react(),
4389
+ ...stylistic(),
4364
4390
  ...presetLangsExtensions,
4365
4391
  ...progress()
4366
4392
  ];
4367
- const aiou = (config = []) => {
4393
+ const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4368
4394
  const configs = [...presetDefault];
4369
4395
  if (isPackageExists("tailwindcss")) {
4370
4396
  configs.push(...tailwindcss());
@@ -4372,6 +4398,9 @@ const aiou = (config = []) => {
4372
4398
  if (isPackageExists("next")) {
4373
4399
  configs.push(...next());
4374
4400
  }
4401
+ if (ssr) {
4402
+ configs.push(...ssrReact());
4403
+ }
4375
4404
  if (Object.keys(config).length > 0) {
4376
4405
  configs.push(...Array.isArray(config) ? config : [config]);
4377
4406
  }
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const comments: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const comments: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const ignores: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const ignores: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const imports: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const imports: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const javascript: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const javascript: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const jsonc: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const jsonc: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const markdown: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const markdown: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const next: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const next: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const progress: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const progress: () => FlatESLintConfig[];
@@ -1,2 +1,3 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const react: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const react: () => FlatESLintConfig[];
3
+ export declare const ssrReact: () => FlatESLintConfig[];
@@ -0,0 +1,2 @@
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const stylistic: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const tailwindcss: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const tailwindcss: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const typescript: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const typescript: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const unicorn: () => FlatESLintConfigItem[];
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const unicorn: () => FlatESLintConfig[];
@@ -1,2 +1,2 @@
1
- import type { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const yml: () => FlatESLintConfigItem[];
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 { FlatESLintConfigItem } from 'eslint-define-config';
2
- export declare const aiou: (config?: FlatESLintConfigItem | FlatESLintConfigItem[]) => FlatESLintConfigItem[];
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.6",
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": "^1.24.1",
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",