@coko/lint 3.0.0-alpha.9 → 3.0.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,51 +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'
13
- import vitest from '@vitest/eslint-plugin'
14
6
  import workspaces from 'eslint-plugin-workspaces'
15
- // import jest from 'eslint-plugin-jest'
16
- // import cypressPlugin from 'eslint-plugin-cypress'
17
-
18
- // const __filename = fileURLToPath(import.meta.url)
19
- // const __dirname = path.dirname(__filename)
20
-
21
- // const compat = new FlatCompat({
22
- // // baseDirectory: __dirname,
23
- // resolvePluginsRelativeTo: import.meta.url,
24
- // // recommendedConfig: js.configs.recommended,
25
- // // allConfig: js.configs.all,
26
- // })
27
-
28
- /**
29
- * TO DO
30
- *
31
- * explicit rules from old config
32
- * jest
33
- * cypress
34
- *
35
- * => client
36
- * no console
37
- * jsx a11y
38
- * airbnb react
39
- * react recommended
40
- * react hooks
41
- * confusing-browser-globals
42
- *
43
- * => drop dependencies
44
- * airbnb
45
- * @eslint/eslintrc (if not using flat compat)
46
- * babel eslint parser
47
- *
48
- */
7
+ import pluginPromise from 'eslint-plugin-promise'
8
+ import nodePlugin from 'eslint-plugin-n'
9
+ import pluginCypress from 'eslint-plugin-cypress'
10
+ import vitest from '@vitest/eslint-plugin'
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'
49
15
 
50
16
  const commonRules = {
51
17
  'array-callback-return': 'error',
@@ -110,7 +76,9 @@ const commonRules = {
110
76
  'ignorePackages',
111
77
  {
112
78
  js: 'never',
79
+ jsx: 'never',
113
80
  ts: 'never',
81
+ tsx: 'never',
114
82
  },
115
83
  ],
116
84
  'import/no-absolute-path': 'error',
@@ -121,8 +89,7 @@ const commonRules = {
121
89
  devDependencies: [
122
90
  // storybook
123
91
  '.storybook/*',
124
- '**/stories/**/*.js',
125
- '**/stories/**/*.ts',
92
+ '**/stories/**/*',
126
93
 
127
94
  // tests
128
95
  'cypress/**',
@@ -133,19 +100,11 @@ const commonRules = {
133
100
  '**/__tests__/**/*',
134
101
  '**/vitest.config.*',
135
102
 
136
- // webpack
137
- 'webpack/**',
138
-
139
103
  // configs
140
- '.commitlintrc.js',
141
- '.commitlintrc.ts',
142
- '.commitlintrc.mjs',
143
104
  '.cz-config.js',
144
105
  '.cz-config.ts',
145
106
  '.cz-config.mjs',
146
- '.jest.config.js',
147
- '.jest.config.ts',
148
- '.jest.config.mjs',
107
+ '.cz-config.cjs',
149
108
  '.lintstagedrc.js',
150
109
  '.lintstagedrc.ts',
151
110
  '.lintstagedrc.mjs',
@@ -169,137 +128,273 @@ const commonRules = {
169
128
  'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
170
129
  }
171
130
 
172
- const server = [
173
- js.configs.recommended,
174
- importPlugin.flatConfigs.recommended,
131
+ const workspacesConfig = {
132
+ plugins: { workspaces },
133
+ rules: {
134
+ 'workspaces/no-relative-imports': 'error',
135
+ 'workspaces/require-dependency': 'warn',
136
+ },
137
+ }
175
138
 
176
- {
177
- plugins: { workspaces },
178
- rules: {
179
- 'workspaces/no-relative-imports': 'error',
180
- 'workspaces/require-dependency': 'warn',
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
+ },
181
209
  },
210
+ n: { tryExtensions: ['.js', '.ts'] },
182
211
  },
212
+ rules: {
213
+ ...commonRules,
214
+ 'no-console': 'error',
215
+ // 'n/no-process-exit': 'off',
216
+ 'import/no-unresolved': ['error', { commonjs: true }],
217
+ },
218
+ }
183
219
 
184
- {
185
- files: ['**/*.{js,mjs,ts}'],
186
- languageOptions: {
187
- globals: { ...globals.node },
188
- ecmaVersion: 'latest',
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',
189
243
  },
190
- plugins: {
191
- n: nodePlugin,
244
+ ecmaVersion: 'latest',
245
+ sourceType: 'module',
246
+ parserOptions: {
247
+ ecmaFeatures: {
248
+ jsx: true,
249
+ },
192
250
  },
193
- settings: {
194
- 'import/resolver': {
195
- typescript: {
196
- alwaysTryTypes: true,
197
- },
251
+ },
252
+ settings: {
253
+ 'import/resolver': {
254
+ typescript: {
255
+ alwaysTryTypes: true,
198
256
  },
199
- n: { tryExtensions: ['.js', '.ts'] },
200
257
  },
201
- rules: {
202
- ...commonRules,
203
- 'no-console': 'error',
204
- // 'n/no-process-exit': 'off',
205
- 'import/no-unresolved': ['error', { commonjs: true }],
258
+ react: {
259
+ version: 'detect',
206
260
  },
207
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
+ }
208
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
+ */
209
322
  {
210
- files: ['**/*.js'],
211
- languageOptions: {
212
- sourceType: 'commonjs',
213
- },
214
- rules: {
215
- ...nodePlugin.configs['flat/recommended-script'].rules,
216
- },
323
+ ...serverFiles,
324
+ ignores: ['packages/client/**', 'cypress/**'],
217
325
  },
218
326
 
219
- // {
220
- // files: ['**/*.mjs', '**/*.ts'],
221
- // languageOptions: {
222
- // sourceType: 'module',
223
- // },
224
- // rules: {
225
- // // 'no-restricted-globals': [
226
- // // 'error',
227
- // // {
228
- // // name: '__dirname',
229
- // // message:
230
- // // 'Do not use __dirname; use import.meta.url or process.cwd().',
231
- // // },
232
- // // {
233
- // // name: '__filename',
234
- // // message:
235
- // // 'Do not use __filename in ES modules or TypeScript; use import.meta.url or path.resolve() instead.',
236
- // // },
237
- // // ],
238
- // },
239
- // },
327
+ {
328
+ ...serverCommonjs,
329
+ ignores: ['packages/client/**', 'cypress/**'],
330
+ },
240
331
 
241
332
  {
242
- files: ['**/*.mjs'],
243
- rules: {
244
- ...nodePlugin.configs['flat/recommended-module'].rules,
245
- },
333
+ ...serverMjs,
334
+ ignores: ['packages/client/**', 'cypress/**'],
246
335
  },
247
336
 
337
+ /**
338
+ * CYPRESS
339
+ */
340
+
248
341
  {
249
- files: ['**/*.ts'],
342
+ files: ['cypress/**/*.{js,mjs,ts}'],
343
+ extends: [pluginCypress.configs.recommended],
250
344
  languageOptions: {
251
- parser: tseslint.parser,
252
- },
253
- plugins: {
254
- '@typescript-eslint': tseslint.plugin,
255
- },
256
- rules: {
257
- ...tseslint.configs.recommended.rules,
258
- '@typescript-eslint/explicit-function-return-type': 'error',
259
-
260
- 'no-redeclare': 'off',
261
- '@typescript-eslint/no-redeclare': 'error',
262
-
263
- 'no-unused-vars': 'off',
264
- '@typescript-eslint/no-unused-vars': [
265
- 'error',
266
- {
267
- argsIgnorePattern: '^_',
268
- varsIgnorePattern: '^_',
269
- caughtErrorsIgnorePattern: '^_',
270
- },
271
- ],
345
+ sourceType: 'module',
346
+ globals: {
347
+ ...globals.browser,
348
+ },
272
349
  },
273
350
  },
274
351
 
352
+ /**
353
+ * CLIENT
354
+ */
355
+
275
356
  {
276
- files: ['**/__tests__/**/*.test.ts'],
277
- plugins: {
278
- vitest,
279
- },
280
- // settings: {
281
- // vitest: {
282
- // typecheck: true,
283
- // },
284
- // },
285
- rules: {
286
- ...vitest.configs.recommended.rules,
287
- },
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}'],
288
364
  },
289
365
 
290
- globalIgnores([
291
- '**/_build',
292
- '**/dist',
293
- '**/docs',
294
- '!**/.storybook',
295
- '!**/.commitlintrc.js',
296
- '!**/.cz-config.js',
297
- '!**/.jest.config.js',
298
- '!**/.lintstagedrc.js',
299
- '!**/.prettierrc.js',
300
- '!**/.stylelintrc.js',
301
- '**/node_modules',
302
- ]),
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),
303
393
  ]
304
394
 
305
- 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
+ }