@coko/lint 3.0.0-alpha.8 → 3.0.0-beta.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/src/eslint.bak.js CHANGED
@@ -1,106 +1,106 @@
1
- module.exports = {
2
- parser: '@babel/eslint-parser',
3
- parserOptions: {
4
- requireConfigFile: false,
5
- babelOptions: {
6
- presets: ['@babel/preset-react'],
7
- },
8
- },
9
- overrides: [
10
- {
11
- files: ['*.jsx'],
12
- },
13
- ],
14
- env: {
15
- browser: true,
16
- es6: true,
17
- jest: true,
18
- node: true,
19
- },
20
- extends: [
21
- 'airbnb',
22
- 'standard',
23
- 'standard-react',
24
- 'plugin:jest/recommended',
25
- 'plugin:cypress/recommended',
26
- 'prettier',
27
- ],
28
- plugins: ['jest'],
29
- ignorePatterns: [
30
- '_build',
31
- 'dist',
32
- '!.storybook',
33
- '!.commitlintrc.js',
34
- '!.cz-config.js',
35
- '!.eslintrc.js',
36
- '!.jest.config.js',
37
- '!.lintstagedrc.js',
38
- '!.prettierrc.js',
39
- '!.stylelintrc.js',
40
- '**/node_modules',
41
- ],
42
- rules: {
43
- 'arrow-body-style': 0,
44
- 'import/no-extraneous-dependencies': [
45
- 'error',
46
- {
47
- devDependencies: [
48
- // storybook
49
- '.storybook/*',
50
- '**/stories/**/*.js',
1
+ // module.exports = {
2
+ // parser: '@babel/eslint-parser',
3
+ // parserOptions: {
4
+ // requireConfigFile: false,
5
+ // babelOptions: {
6
+ // presets: ['@babel/preset-react'],
7
+ // },
8
+ // },
9
+ // overrides: [
10
+ // {
11
+ // files: ['*.jsx'],
12
+ // },
13
+ // ],
14
+ // env: {
15
+ // browser: true,
16
+ // es6: true,
17
+ // jest: true,
18
+ // node: true,
19
+ // },
20
+ // extends: [
21
+ // 'airbnb',
22
+ // 'standard',
23
+ // 'standard-react',
24
+ // 'plugin:jest/recommended',
25
+ // 'plugin:cypress/recommended',
26
+ // 'prettier',
27
+ // ],
28
+ // plugins: ['jest'],
29
+ // ignorePatterns: [
30
+ // '_build',
31
+ // 'dist',
32
+ // '!.storybook',
33
+ // '!.commitlintrc.js',
34
+ // '!.cz-config.js',
35
+ // '!.eslintrc.js',
36
+ // '!.jest.config.js',
37
+ // '!.lintstagedrc.js',
38
+ // '!.prettierrc.js',
39
+ // '!.stylelintrc.js',
40
+ // '**/node_modules',
41
+ // ],
42
+ // rules: {
43
+ // 'arrow-body-style': 0,
44
+ // 'import/no-extraneous-dependencies': [
45
+ // 'error',
46
+ // {
47
+ // devDependencies: [
48
+ // // storybook
49
+ // '.storybook/*',
50
+ // '**/stories/**/*.js',
51
51
 
52
- // tests
53
- 'cypress/**',
54
- '**/*.spec.js',
55
- '**/*.test.js',
52
+ // // tests
53
+ // 'cypress/**',
54
+ // '**/*.spec.js',
55
+ // '**/*.test.js',
56
56
 
57
- // webpack
58
- 'webpack/**',
57
+ // // webpack
58
+ // 'webpack/**',
59
59
 
60
- // configs
61
- '.commitlintrc.js',
62
- '.cz-config.js',
63
- '.eslintrc.js',
64
- '.jest.config.js',
65
- '.lintstagedrc.js',
66
- '.prettierrc.js',
67
- '.stylelintrc.js',
60
+ // // configs
61
+ // '.commitlintrc.js',
62
+ // '.cz-config.js',
63
+ // '.eslintrc.js',
64
+ // '.jest.config.js',
65
+ // '.lintstagedrc.js',
66
+ // '.prettierrc.js',
67
+ // '.stylelintrc.js',
68
68
 
69
- // other
70
- 'dev/**',
71
- ],
72
- },
73
- ],
74
- 'jsx-a11y/anchor-is-valid': [
75
- 'error',
76
- {
77
- components: ['Link'],
78
- specialLink: ['to', 'hrefLeft', 'hrefRight'],
79
- aspects: ['noHref', 'invalidHref', 'preferButton'],
80
- },
81
- ],
82
- 'no-console': ['error', { allow: ['warn', 'error'] }],
83
- 'padding-line-between-statements': [
84
- 'error',
85
- { blankLine: 'always', prev: '*', next: 'block' },
86
- { blankLine: 'always', prev: 'block', next: '*' },
87
- { blankLine: 'always', prev: '*', next: 'block-like' },
88
- { blankLine: 'always', prev: 'block-like', next: '*' },
89
- { blankLine: 'always', prev: '*', next: 'multiline-const' },
90
- { blankLine: 'always', prev: 'multiline-const', next: '*' },
91
- ],
92
- // 'prettier/prettier': 'error',
93
- 'react/function-component-definition': [
94
- 2,
95
- { namedComponents: 'arrow-function' },
96
- ],
97
- 'react/jsx-filename-extension': [2, { extensions: ['.js'] }], // disallows .jsx files
98
- 'react/jsx-props-no-spreading': 0,
99
- 'react/jsx-sort-props': [1, { ignoreCase: true }],
100
- 'react/prop-types': [
101
- 2,
102
- { ignore: ['children', 'className', 'onClick', 'theme'] },
103
- ],
104
- // 'sort-keys': [1, 'asc', { caseSensitive: false }],
105
- },
106
- }
69
+ // // other
70
+ // 'dev/**',
71
+ // ],
72
+ // },
73
+ // ],
74
+ // 'jsx-a11y/anchor-is-valid': [
75
+ // 'error',
76
+ // {
77
+ // components: ['Link'],
78
+ // specialLink: ['to', 'hrefLeft', 'hrefRight'],
79
+ // aspects: ['noHref', 'invalidHref', 'preferButton'],
80
+ // },
81
+ // ],
82
+ // 'no-console': ['error', { allow: ['warn', 'error'] }],
83
+ // 'padding-line-between-statements': [
84
+ // 'error',
85
+ // { blankLine: 'always', prev: '*', next: 'block' },
86
+ // { blankLine: 'always', prev: 'block', next: '*' },
87
+ // { blankLine: 'always', prev: '*', next: 'block-like' },
88
+ // { blankLine: 'always', prev: 'block-like', next: '*' },
89
+ // { blankLine: 'always', prev: '*', next: 'multiline-const' },
90
+ // { blankLine: 'always', prev: 'multiline-const', next: '*' },
91
+ // ],
92
+ // // 'prettier/prettier': 'error',
93
+ // 'react/function-component-definition': [
94
+ // 2,
95
+ // { namedComponents: 'arrow-function' },
96
+ // ],
97
+ // 'react/jsx-filename-extension': [2, { extensions: ['.js'] }], // disallows .jsx files
98
+ // 'react/jsx-props-no-spreading': 0,
99
+ // 'react/jsx-sort-props': [1, { ignoreCase: true }],
100
+ // 'react/prop-types': [
101
+ // 2,
102
+ // { ignore: ['children', 'className', 'onClick', 'theme'] },
103
+ // ],
104
+ // // 'sort-keys': [1, 'asc', { caseSensitive: false }],
105
+ // },
106
+ // }
package/src/eslint.mjs CHANGED
@@ -1,50 +1,17 @@
1
- // import path from 'path'
2
-
3
1
  import { defineConfig, globalIgnores } from 'eslint/config'
4
2
  import js from '@eslint/js'
5
- // import { FlatCompat } from '@eslint/eslintrc'
6
-
7
3
  import globals from 'globals'
8
4
  import tseslint from 'typescript-eslint'
9
- // import babelParser from '@babel/eslint-parser'
10
-
11
- import nodePlugin from 'eslint-plugin-n'
12
5
  import importPlugin from 'eslint-plugin-import'
6
+ import workspaces from 'eslint-plugin-workspaces'
7
+ import pluginPromise from 'eslint-plugin-promise'
8
+ import nodePlugin from 'eslint-plugin-n'
9
+ import pluginCypress from 'eslint-plugin-cypress'
13
10
  import vitest from '@vitest/eslint-plugin'
14
- // import jest from 'eslint-plugin-jest'
15
- // import cypressPlugin from 'eslint-plugin-cypress'
16
-
17
- // const __filename = fileURLToPath(import.meta.url)
18
- // const __dirname = path.dirname(__filename)
19
-
20
- // const compat = new FlatCompat({
21
- // // baseDirectory: __dirname,
22
- // resolvePluginsRelativeTo: import.meta.url,
23
- // // recommendedConfig: js.configs.recommended,
24
- // // allConfig: js.configs.all,
25
- // })
26
-
27
- /**
28
- * TO DO
29
- *
30
- * explicit rules from old config
31
- * jest
32
- * cypress
33
- *
34
- * => client
35
- * no console
36
- * jsx a11y
37
- * airbnb react
38
- * react recommended
39
- * react hooks
40
- * confusing-browser-globals
41
- *
42
- * => drop dependencies
43
- * airbnb
44
- * @eslint/eslintrc (if not using flat compat)
45
- * babel eslint parser
46
- *
47
- */
11
+ import react from 'eslint-plugin-react'
12
+ import reactHooks from 'eslint-plugin-react-hooks'
13
+ import jsxA11y from 'eslint-plugin-jsx-a11y'
14
+ import confusingBrowserGlobals from 'confusing-browser-globals'
48
15
 
49
16
  const commonRules = {
50
17
  'array-callback-return': 'error',
@@ -109,7 +76,9 @@ const commonRules = {
109
76
  'ignorePackages',
110
77
  {
111
78
  js: 'never',
79
+ jsx: 'never',
112
80
  ts: 'never',
81
+ tsx: 'never',
113
82
  },
114
83
  ],
115
84
  'import/no-absolute-path': 'error',
@@ -120,8 +89,7 @@ const commonRules = {
120
89
  devDependencies: [
121
90
  // storybook
122
91
  '.storybook/*',
123
- '**/stories/**/*.js',
124
- '**/stories/**/*.ts',
92
+ '**/stories/**/*',
125
93
 
126
94
  // tests
127
95
  'cypress/**',
@@ -132,19 +100,11 @@ const commonRules = {
132
100
  '**/__tests__/**/*',
133
101
  '**/vitest.config.*',
134
102
 
135
- // webpack
136
- 'webpack/**',
137
-
138
103
  // configs
139
- '.commitlintrc.js',
140
- '.commitlintrc.ts',
141
- '.commitlintrc.mjs',
142
104
  '.cz-config.js',
143
105
  '.cz-config.ts',
144
106
  '.cz-config.mjs',
145
- '.jest.config.js',
146
- '.jest.config.ts',
147
- '.jest.config.mjs',
107
+ '.cz-config.cjs',
148
108
  '.lintstagedrc.js',
149
109
  '.lintstagedrc.ts',
150
110
  '.lintstagedrc.mjs',
@@ -168,129 +128,273 @@ const commonRules = {
168
128
  'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
169
129
  }
170
130
 
171
- const server = [
172
- js.configs.recommended,
173
- importPlugin.flatConfigs.recommended,
131
+ const workspacesConfig = {
132
+ plugins: { workspaces },
133
+ rules: {
134
+ 'workspaces/no-relative-imports': 'error',
135
+ 'workspaces/require-dependency': 'warn',
136
+ },
137
+ }
174
138
 
175
- {
176
- files: ['**/*.{js,mjs,ts}'],
177
- languageOptions: {
178
- globals: { ...globals.node },
179
- ecmaVersion: 'latest',
139
+ const typescriptConfig = {
140
+ files: ['**/*.{ts,tsx}'],
141
+ languageOptions: {
142
+ parser: tseslint.parser,
143
+ },
144
+ plugins: {
145
+ '@typescript-eslint': tseslint.plugin,
146
+ },
147
+ rules: {
148
+ ...tseslint.configs.recommended.rules,
149
+ '@typescript-eslint/explicit-function-return-type': 'error',
150
+
151
+ 'no-redeclare': 'off',
152
+ '@typescript-eslint/no-redeclare': 'error',
153
+
154
+ 'no-unused-vars': 'off',
155
+ '@typescript-eslint/no-unused-vars': [
156
+ 'error',
157
+ {
158
+ argsIgnorePattern: '^_',
159
+ varsIgnorePattern: '^_',
160
+ caughtErrorsIgnorePattern: '^_',
161
+ },
162
+ ],
163
+ },
164
+ }
165
+
166
+ const viteConfig = {
167
+ files: ['**/__tests__/**/*.test.ts'],
168
+ plugins: {
169
+ vitest,
170
+ },
171
+ // settings: {
172
+ // vitest: {
173
+ // typecheck: true,
174
+ // },
175
+ // },
176
+ rules: {
177
+ ...vitest.configs.recommended.rules,
178
+ 'vitest/no-focused-tests': ['error', { fixable: false }],
179
+ },
180
+ }
181
+
182
+ const globalIgnoreList = [
183
+ '**/_build',
184
+ '**/dist',
185
+ '**/docs',
186
+ '!**/.storybook',
187
+ '!**/.cz-config.js',
188
+ '!**/.cz-config.cjs',
189
+ '!**/.lintstagedrc.js',
190
+ '!**/.prettierrc.js',
191
+ '!**/.stylelintrc.js',
192
+ '**/node_modules',
193
+ ]
194
+
195
+ const serverFiles = {
196
+ files: ['**/*.{js,mjs,ts}'],
197
+ languageOptions: {
198
+ globals: { ...globals.node },
199
+ ecmaVersion: 'latest',
200
+ },
201
+ plugins: {
202
+ n: nodePlugin,
203
+ },
204
+ settings: {
205
+ 'import/resolver': {
206
+ typescript: {
207
+ alwaysTryTypes: true,
208
+ },
180
209
  },
181
- plugins: {
182
- n: nodePlugin,
210
+ n: { tryExtensions: ['.js', '.ts'] },
211
+ },
212
+ rules: {
213
+ ...commonRules,
214
+ 'no-console': 'error',
215
+ // 'n/no-process-exit': 'off',
216
+ 'import/no-unresolved': ['error', { commonjs: true }],
217
+ },
218
+ }
219
+
220
+ const serverCommonjs = {
221
+ files: ['**/*.js'],
222
+ languageOptions: {
223
+ sourceType: 'commonjs',
224
+ },
225
+ rules: {
226
+ ...nodePlugin.configs['flat/recommended-script'].rules,
227
+ },
228
+ }
229
+
230
+ const serverMjs = {
231
+ files: ['**/*.mjs'],
232
+ rules: {
233
+ ...nodePlugin.configs['flat/recommended-module'].rules,
234
+ },
235
+ }
236
+
237
+ const clientFiles = {
238
+ files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
239
+ languageOptions: {
240
+ globals: {
241
+ ...globals.browser,
242
+ process: 'readonly',
243
+ },
244
+ ecmaVersion: 'latest',
245
+ sourceType: 'module',
246
+ parserOptions: {
247
+ ecmaFeatures: {
248
+ jsx: true,
249
+ },
183
250
  },
184
- settings: {
185
- 'import/resolver': {
186
- typescript: {
187
- alwaysTryTypes: true,
188
- },
251
+ },
252
+ settings: {
253
+ 'import/resolver': {
254
+ typescript: {
255
+ alwaysTryTypes: true,
189
256
  },
190
- n: { tryExtensions: ['.js', '.ts'] },
191
257
  },
192
- rules: {
193
- ...commonRules,
194
- 'no-console': 'error',
195
- // 'n/no-process-exit': 'off',
196
- 'import/no-unresolved': ['error', { commonjs: true }],
258
+ react: {
259
+ version: 'detect',
197
260
  },
198
261
  },
262
+ rules: {
263
+ ...commonRules,
264
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
265
+ 'import/no-unresolved': 'error',
266
+ 'react/jsx-sort-props': [1, { ignoreCase: true }],
267
+ 'no-restricted-globals': ['error'].concat(confusingBrowserGlobals),
268
+ },
269
+ }
199
270
 
271
+ const clientCommonjs = {
272
+ files: ['**/*.cjs'],
273
+ languageOptions: { sourceType: 'commonjs' },
274
+ }
275
+
276
+ const server = [
277
+ js.configs.recommended,
278
+ importPlugin.flatConfigs.recommended,
279
+ pluginPromise.configs['flat/recommended'],
280
+ workspacesConfig,
281
+
282
+ serverFiles,
283
+ serverCommonjs,
284
+ serverMjs,
285
+
286
+ typescriptConfig,
287
+ viteConfig,
288
+ globalIgnores(globalIgnoreList),
289
+ ]
290
+
291
+ const client = [
292
+ js.configs.recommended,
293
+ importPlugin.flatConfigs.recommended,
294
+ pluginPromise.configs['flat/recommended'],
295
+ workspacesConfig,
296
+
297
+ react.configs.flat.recommended,
298
+ react.configs.flat['jsx-runtime'],
299
+ reactHooks.configs.flat.recommended,
300
+ jsxA11y.flatConfigs.recommended,
301
+
302
+ clientFiles,
303
+ clientCommonjs,
304
+
305
+ typescriptConfig,
306
+ viteConfig,
307
+ globalIgnores(globalIgnoreList),
308
+ ]
309
+
310
+ const root = [
311
+ /**
312
+ * COMMON 1
313
+ */
314
+ js.configs.recommended,
315
+ importPlugin.flatConfigs.recommended,
316
+ pluginPromise.configs['flat/recommended'],
317
+ workspacesConfig,
318
+
319
+ /**
320
+ * SERVER
321
+ */
200
322
  {
201
- files: ['**/*.js'],
202
- languageOptions: {
203
- sourceType: 'commonjs',
204
- },
205
- rules: {
206
- ...nodePlugin.configs['flat/recommended-script'].rules,
207
- },
323
+ ...serverFiles,
324
+ ignores: ['packages/client/**', 'cypress/**'],
208
325
  },
209
326
 
210
- // {
211
- // files: ['**/*.mjs', '**/*.ts'],
212
- // languageOptions: {
213
- // sourceType: 'module',
214
- // },
215
- // rules: {
216
- // // 'no-restricted-globals': [
217
- // // 'error',
218
- // // {
219
- // // name: '__dirname',
220
- // // message:
221
- // // 'Do not use __dirname; use import.meta.url or process.cwd().',
222
- // // },
223
- // // {
224
- // // name: '__filename',
225
- // // message:
226
- // // 'Do not use __filename in ES modules or TypeScript; use import.meta.url or path.resolve() instead.',
227
- // // },
228
- // // ],
229
- // },
230
- // },
327
+ {
328
+ ...serverCommonjs,
329
+ ignores: ['packages/client/**', 'cypress/**'],
330
+ },
231
331
 
232
332
  {
233
- files: ['**/*.mjs'],
234
- rules: {
235
- ...nodePlugin.configs['flat/recommended-module'].rules,
236
- },
333
+ ...serverMjs,
334
+ ignores: ['packages/client/**', 'cypress/**'],
237
335
  },
238
336
 
337
+ /**
338
+ * CYPRESS
339
+ */
340
+
239
341
  {
240
- files: ['**/*.ts'],
342
+ files: ['cypress/**/*.{js,mjs,ts}'],
343
+ extends: [pluginCypress.configs.recommended],
241
344
  languageOptions: {
242
- parser: tseslint.parser,
243
- },
244
- plugins: {
245
- '@typescript-eslint': tseslint.plugin,
246
- },
247
- rules: {
248
- ...tseslint.configs.recommended.rules,
249
- '@typescript-eslint/explicit-function-return-type': 'error',
250
-
251
- 'no-redeclare': 'off',
252
- '@typescript-eslint/no-redeclare': 'error',
253
-
254
- 'no-unused-vars': 'off',
255
- '@typescript-eslint/no-unused-vars': [
256
- 'error',
257
- {
258
- argsIgnorePattern: '^_',
259
- varsIgnorePattern: '^_',
260
- caughtErrorsIgnorePattern: '^_',
261
- },
262
- ],
345
+ sourceType: 'module',
346
+ globals: {
347
+ ...globals.browser,
348
+ },
263
349
  },
264
350
  },
265
351
 
352
+ /**
353
+ * CLIENT
354
+ */
355
+
266
356
  {
267
- files: ['**/__tests__/**/*.test.ts'],
268
- plugins: {
269
- vitest,
270
- },
271
- // settings: {
272
- // vitest: {
273
- // typecheck: true,
274
- // },
275
- // },
276
- rules: {
277
- ...vitest.configs.recommended.rules,
278
- },
357
+ ...react.configs.flat.recommended,
358
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
359
+ },
360
+
361
+ {
362
+ ...react.configs.flat['jsx-runtime'],
363
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
279
364
  },
280
365
 
281
- globalIgnores([
282
- '**/_build',
283
- '**/dist',
284
- '**/docs',
285
- '!**/.storybook',
286
- '!**/.commitlintrc.js',
287
- '!**/.cz-config.js',
288
- '!**/.jest.config.js',
289
- '!**/.lintstagedrc.js',
290
- '!**/.prettierrc.js',
291
- '!**/.stylelintrc.js',
292
- '**/node_modules',
293
- ]),
366
+ {
367
+ ...reactHooks.configs.flat.recommended,
368
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
369
+ },
370
+
371
+ {
372
+ ...jsxA11y.flatConfigs.recommended,
373
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
374
+ },
375
+
376
+ {
377
+ ...clientFiles,
378
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
379
+ },
380
+
381
+ {
382
+ ...clientCommonjs,
383
+ files: ['packages/client/**/*.cjs'],
384
+ },
385
+
386
+ /**
387
+ * COMMON 2
388
+ */
389
+
390
+ typescriptConfig,
391
+ viteConfig,
392
+ globalIgnores(globalIgnoreList),
294
393
  ]
295
394
 
296
- export { defineConfig as defineEslintConfig, server as serverEslintConfig }
395
+ export {
396
+ defineConfig as defineEslintConfig,
397
+ server as serverEslintConfig,
398
+ client as clientEslintConfig,
399
+ root as rootEslintConfig,
400
+ }