@aiou/eslint-config 1.1.0 → 1.2.1

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
@@ -38,9 +38,15 @@ module.exports = aiou()
38
38
 
39
39
  #### `options.ssr`
40
40
 
41
- - default: `false`
41
+ - default: `true`
42
42
 
43
43
  enabled ssr-friendly rules
44
+
45
+ #### `options.regexp`
46
+
47
+ - default: `true`
48
+
49
+ enabled regexp rules
44
50
 
45
51
  ## rules
46
52
 
@@ -51,7 +57,7 @@ eslint-config-standard
51
57
  eslint-plugin-eslint-comments
52
58
  eslint-plugin-html
53
59
  eslint-plugin-i
54
- eslint-plugin-regexp
60
+ eslint-plugin-regexp (configured when regexp enabled)
55
61
  eslint-plugin-markdown
56
62
  eslint-plugin-simple-import-sort
57
63
  eslint-plugin-import-newlines
package/dist/index.cjs CHANGED
@@ -9,7 +9,6 @@ var pluginSimpleImportSort = require('eslint-plugin-simple-import-sort');
9
9
  var pluginUnsedImports = require('eslint-plugin-unused-imports');
10
10
  var pluginN = require('eslint-plugin-n');
11
11
  var pluginPromise = require('eslint-plugin-promise');
12
- var pluginRegexp = require('eslint-plugin-regexp');
13
12
  var globals$1 = require('globals');
14
13
  var pluginJsonc = require('eslint-plugin-jsonc');
15
14
  var jsoncParser = require('jsonc-eslint-parser');
@@ -20,6 +19,7 @@ var pluginReact = require('eslint-plugin-react');
20
19
  var pluginReactHooks = require('eslint-plugin-react-hooks');
21
20
  var pluginReactRefresh = require('eslint-plugin-react-refresh');
22
21
  var pluginSSRFriendly = require('eslint-plugin-ssr-friendly');
22
+ var pluginRegexp = require('eslint-plugin-regexp');
23
23
  var pluginStylistic = require('@stylistic/eslint-plugin');
24
24
  var node_module = require('node:module');
25
25
  var pluginTypeScript = require('@typescript-eslint/eslint-plugin');
@@ -125,7 +125,7 @@ const imports = () => {
125
125
  "import-newlines/enforce": [
126
126
  "error",
127
127
  {
128
- items: 4,
128
+ items: 2,
129
129
  "max-len": 120,
130
130
  semi: false
131
131
  }
@@ -155,7 +155,9 @@ const imports = () => {
155
155
  `**/App*.${GLOB_SCRIPT_EXT}`,
156
156
  `**/Document.${GLOB_SCRIPT_EXT}`,
157
157
  "**/{vite,esbuild,rollup,webpack,rspack}.ts",
158
- GLOB_DTS
158
+ GLOB_DTS,
159
+ GLOB_TEST_SCRIPT,
160
+ GLOB_TEST_DIRS
159
161
  ],
160
162
  rules: {
161
163
  // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
@@ -836,12 +838,10 @@ const javascript = () => {
836
838
  },
837
839
  plugins: {
838
840
  n: pluginN,
839
- promise: pluginPromise,
840
- regexp: pluginRegexp
841
+ promise: pluginPromise
841
842
  },
842
843
  rules: {
843
844
  ...pluginStandard.rules,
844
- ...pluginRegexp.configs.recommended.rules,
845
845
  curly: ["error", "all"],
846
846
  "no-unused-vars": "warn",
847
847
  "no-param-reassign": "off",
@@ -1184,7 +1184,11 @@ const markdown = () => {
1184
1184
  "no-unused-expressions": "off",
1185
1185
  "no-unused-vars": "off",
1186
1186
  // Off imports
1187
- "import/no-extraneous-dependencies": "off"
1187
+ "import/no-extraneous-dependencies": "off",
1188
+ "import/no-default-export": "off",
1189
+ "import/no-anonymous-default-export": "off",
1190
+ "react-refresh/only-export-components": "off",
1191
+ "react/jsx-no-undef": "off"
1188
1192
  }
1189
1193
  }
1190
1194
  ];
@@ -4000,6 +4004,17 @@ const react = () => {
4000
4004
  // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
4001
4005
  "react-refresh/only-export-components": "warn"
4002
4006
  }
4007
+ },
4008
+ {
4009
+ files: [
4010
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
4011
+ `**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
4012
+ GLOB_TEST_SCRIPT,
4013
+ GLOB_TEST_DIRS
4014
+ ],
4015
+ rules: {
4016
+ "react-refresh/only-export-components": "off"
4017
+ }
4003
4018
  }
4004
4019
  ];
4005
4020
  return config;
@@ -4028,10 +4043,55 @@ const ssrReact = () => {
4028
4043
  }
4029
4044
  },
4030
4045
  {
4031
- files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
4046
+ files: [
4047
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
4048
+ // Client entry files not need to be SSR friendly
4049
+ `**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
4050
+ GLOB_TEST_SCRIPT,
4051
+ GLOB_TEST_DIRS
4052
+ ],
4032
4053
  rules: {
4033
- ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
4034
- "ssr-friendly/only-export-components": "off"
4054
+ ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off")
4055
+ }
4056
+ }
4057
+ ];
4058
+ return config;
4059
+ };
4060
+
4061
+ const regexp = () => {
4062
+ const config = [
4063
+ {
4064
+ languageOptions: {
4065
+ globals: {
4066
+ ...globals$1.browser,
4067
+ ...globals$1.es2021,
4068
+ ...globals$1.node
4069
+ },
4070
+ parserOptions: {
4071
+ ecmaFeatures: {
4072
+ jsx: true
4073
+ },
4074
+ // Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
4075
+ // This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
4076
+ ecmaVersion: "latest",
4077
+ sourceType: "module"
4078
+ },
4079
+ sourceType: "module"
4080
+ },
4081
+ settings: {
4082
+ // This will do the trick
4083
+ "import/parsers": {
4084
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
4085
+ },
4086
+ "import/resolver": {
4087
+ node: true
4088
+ }
4089
+ },
4090
+ plugins: {
4091
+ regexp: pluginRegexp
4092
+ },
4093
+ rules: {
4094
+ ...pluginRegexp.configs.recommended.rules
4035
4095
  }
4036
4096
  }
4037
4097
  ];
@@ -4160,7 +4220,8 @@ const stylistic = () => {
4160
4220
  // < and > should be on the same line(y-axis) if jsx is multiline
4161
4221
  "@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4162
4222
  // Enforce new line when multiline props jsx
4163
- "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
4223
+ "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
4224
+ "@stylistic/jsx-one-expression-per-line": "off"
4164
4225
  }
4165
4226
  }
4166
4227
  ];
@@ -4392,7 +4453,7 @@ const presetDefault = [
4392
4453
  ...presetLangsExtensions,
4393
4454
  ...progress()
4394
4455
  ];
4395
- const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4456
+ const aiou = ({ ssr = true, regexp: regexp$1 = true } = { ssr: true, regexp: true }, config = []) => {
4396
4457
  const configs = [...presetDefault];
4397
4458
  if (localPkg.isPackageExists("tailwindcss")) {
4398
4459
  configs.push(...tailwindcss());
@@ -4403,6 +4464,9 @@ const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4403
4464
  if (ssr) {
4404
4465
  configs.push(...ssrReact());
4405
4466
  }
4467
+ if (regexp$1) {
4468
+ configs.push(...regexp());
4469
+ }
4406
4470
  if (Object.keys(config).length > 0) {
4407
4471
  configs.push(...Array.isArray(config) ? config : [config]);
4408
4472
  }
package/dist/index.mjs CHANGED
@@ -7,7 +7,6 @@ import pluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
7
7
  import pluginUnsedImports from 'eslint-plugin-unused-imports';
8
8
  import pluginN from 'eslint-plugin-n';
9
9
  import pluginPromise from 'eslint-plugin-promise';
10
- import pluginRegexp from 'eslint-plugin-regexp';
11
10
  import globals$1 from 'globals';
12
11
  import pluginJsonc from 'eslint-plugin-jsonc';
13
12
  import jsoncParser from 'jsonc-eslint-parser';
@@ -18,6 +17,7 @@ import pluginReact from 'eslint-plugin-react';
18
17
  import pluginReactHooks from 'eslint-plugin-react-hooks';
19
18
  import pluginReactRefresh from 'eslint-plugin-react-refresh';
20
19
  import pluginSSRFriendly from 'eslint-plugin-ssr-friendly';
20
+ import pluginRegexp from 'eslint-plugin-regexp';
21
21
  import pluginStylistic from '@stylistic/eslint-plugin';
22
22
  import { createRequire } from 'node:module';
23
23
  import pluginTypeScript from '@typescript-eslint/eslint-plugin';
@@ -123,7 +123,7 @@ const imports = () => {
123
123
  "import-newlines/enforce": [
124
124
  "error",
125
125
  {
126
- items: 4,
126
+ items: 2,
127
127
  "max-len": 120,
128
128
  semi: false
129
129
  }
@@ -153,7 +153,9 @@ const imports = () => {
153
153
  `**/App*.${GLOB_SCRIPT_EXT}`,
154
154
  `**/Document.${GLOB_SCRIPT_EXT}`,
155
155
  "**/{vite,esbuild,rollup,webpack,rspack}.ts",
156
- GLOB_DTS
156
+ GLOB_DTS,
157
+ GLOB_TEST_SCRIPT,
158
+ GLOB_TEST_DIRS
157
159
  ],
158
160
  rules: {
159
161
  // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
@@ -834,12 +836,10 @@ const javascript = () => {
834
836
  },
835
837
  plugins: {
836
838
  n: pluginN,
837
- promise: pluginPromise,
838
- regexp: pluginRegexp
839
+ promise: pluginPromise
839
840
  },
840
841
  rules: {
841
842
  ...pluginStandard.rules,
842
- ...pluginRegexp.configs.recommended.rules,
843
843
  curly: ["error", "all"],
844
844
  "no-unused-vars": "warn",
845
845
  "no-param-reassign": "off",
@@ -1182,7 +1182,11 @@ const markdown = () => {
1182
1182
  "no-unused-expressions": "off",
1183
1183
  "no-unused-vars": "off",
1184
1184
  // Off imports
1185
- "import/no-extraneous-dependencies": "off"
1185
+ "import/no-extraneous-dependencies": "off",
1186
+ "import/no-default-export": "off",
1187
+ "import/no-anonymous-default-export": "off",
1188
+ "react-refresh/only-export-components": "off",
1189
+ "react/jsx-no-undef": "off"
1186
1190
  }
1187
1191
  }
1188
1192
  ];
@@ -3998,6 +4002,17 @@ const react = () => {
3998
4002
  // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
3999
4003
  "react-refresh/only-export-components": "warn"
4000
4004
  }
4005
+ },
4006
+ {
4007
+ files: [
4008
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
4009
+ `**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
4010
+ GLOB_TEST_SCRIPT,
4011
+ GLOB_TEST_DIRS
4012
+ ],
4013
+ rules: {
4014
+ "react-refresh/only-export-components": "off"
4015
+ }
4001
4016
  }
4002
4017
  ];
4003
4018
  return config;
@@ -4026,10 +4041,55 @@ const ssrReact = () => {
4026
4041
  }
4027
4042
  },
4028
4043
  {
4029
- files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
4044
+ files: [
4045
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
4046
+ // Client entry files not need to be SSR friendly
4047
+ `**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
4048
+ GLOB_TEST_SCRIPT,
4049
+ GLOB_TEST_DIRS
4050
+ ],
4030
4051
  rules: {
4031
- ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
4032
- "ssr-friendly/only-export-components": "off"
4052
+ ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off")
4053
+ }
4054
+ }
4055
+ ];
4056
+ return config;
4057
+ };
4058
+
4059
+ const regexp = () => {
4060
+ const config = [
4061
+ {
4062
+ languageOptions: {
4063
+ globals: {
4064
+ ...globals$1.browser,
4065
+ ...globals$1.es2021,
4066
+ ...globals$1.node
4067
+ },
4068
+ parserOptions: {
4069
+ ecmaFeatures: {
4070
+ jsx: true
4071
+ },
4072
+ // Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
4073
+ // This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
4074
+ ecmaVersion: "latest",
4075
+ sourceType: "module"
4076
+ },
4077
+ sourceType: "module"
4078
+ },
4079
+ settings: {
4080
+ // This will do the trick
4081
+ "import/parsers": {
4082
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
4083
+ },
4084
+ "import/resolver": {
4085
+ node: true
4086
+ }
4087
+ },
4088
+ plugins: {
4089
+ regexp: pluginRegexp
4090
+ },
4091
+ rules: {
4092
+ ...pluginRegexp.configs.recommended.rules
4033
4093
  }
4034
4094
  }
4035
4095
  ];
@@ -4158,7 +4218,8 @@ const stylistic = () => {
4158
4218
  // < and > should be on the same line(y-axis) if jsx is multiline
4159
4219
  "@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4160
4220
  // Enforce new line when multiline props jsx
4161
- "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"]
4221
+ "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
4222
+ "@stylistic/jsx-one-expression-per-line": "off"
4162
4223
  }
4163
4224
  }
4164
4225
  ];
@@ -4390,7 +4451,7 @@ const presetDefault = [
4390
4451
  ...presetLangsExtensions,
4391
4452
  ...progress()
4392
4453
  ];
4393
- const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4454
+ const aiou = ({ ssr = true, regexp: regexp$1 = true } = { ssr: true, regexp: true }, config = []) => {
4394
4455
  const configs = [...presetDefault];
4395
4456
  if (isPackageExists("tailwindcss")) {
4396
4457
  configs.push(...tailwindcss());
@@ -4401,6 +4462,9 @@ const aiou = ({ ssr = true } = { ssr: true }, config = []) => {
4401
4462
  if (ssr) {
4402
4463
  configs.push(...ssrReact());
4403
4464
  }
4465
+ if (regexp$1) {
4466
+ configs.push(...regexp());
4467
+ }
4404
4468
  if (Object.keys(config).length > 0) {
4405
4469
  configs.push(...Array.isArray(config) ? config : [config]);
4406
4470
  }
@@ -0,0 +1,2 @@
1
+ import type { FlatESLintConfig } from 'eslint-define-config';
2
+ export declare const regexp: () => FlatESLintConfig[];
package/dts/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { FlatESLintConfig } from 'eslint-define-config';
2
2
  interface Options {
3
3
  ssr?: boolean;
4
+ regexp?: boolean;
4
5
  }
5
- export declare const aiou: ({ ssr }?: Options, config?: FlatESLintConfig | FlatESLintConfig[]) => FlatESLintConfig[];
6
+ export declare const aiou: ({ ssr, regexp }?: Options, config?: FlatESLintConfig | FlatESLintConfig[]) => FlatESLintConfig[];
6
7
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiou/eslint-config",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "eslint config for aiou template",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -56,7 +56,7 @@
56
56
  "jsonc-eslint-parser": "^2.4.0",
57
57
  "local-pkg": "^0.4.3",
58
58
  "yaml-eslint-parser": "^1.2.2",
59
- "@aiou/eslint-ignore": "0.5.1",
59
+ "@aiou/eslint-ignore": "0.5.2",
60
60
  "@aiou/eslint-plugin-progress": "0.3.1"
61
61
  },
62
62
  "devDependencies": {