@coko/lint 3.0.0-alpha.3 → 3.0.0-alpha.31

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,49 +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 jest from 'eslint-plugin-jest'
14
- // import cypressPlugin from 'eslint-plugin-cypress'
15
-
16
- // const __filename = fileURLToPath(import.meta.url)
17
- // const __dirname = path.dirname(__filename)
18
-
19
- // const compat = new FlatCompat({
20
- // // baseDirectory: __dirname,
21
- // resolvePluginsRelativeTo: import.meta.url,
22
- // // recommendedConfig: js.configs.recommended,
23
- // // allConfig: js.configs.all,
24
- // })
25
-
26
- /**
27
- * TO DO
28
- *
29
- * explicit rules from old config
30
- * jest
31
- * cypress
32
- *
33
- * => client
34
- * no console
35
- * jsx a11y
36
- * airbnb react
37
- * react recommended
38
- * react hooks
39
- * confusing-browser-globals
40
- *
41
- * => drop dependencies
42
- * airbnb
43
- * @eslint/eslintrc (if not using flat compat)
44
- * babel eslint parser
45
- *
46
- */
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'
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'
47
15
 
48
16
  const commonRules = {
49
17
  'array-callback-return': 'error',
@@ -87,7 +55,6 @@ const commonRules = {
87
55
  'no-template-curly-in-string': 'warn',
88
56
  'no-throw-literal': 'error',
89
57
  'no-undef-init': 'warn',
90
- 'no-undefined': 'error',
91
58
  'no-unneeded-ternary': ['error', { defaultAssignment: false }],
92
59
  'no-unused-expressions': 'error',
93
60
  'no-useless-computed-key': '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,25 +89,33 @@ const commonRules = {
120
89
  devDependencies: [
121
90
  // storybook
122
91
  '.storybook/*',
123
- '**/stories/**/*.js',
92
+ '**/stories/**/*',
124
93
 
125
94
  // tests
126
95
  'cypress/**',
127
96
  '**/*.spec.js',
97
+ '**/*.spec.ts',
128
98
  '**/*.test.js',
99
+ '**/*.test.ts',
129
100
  '**/__tests__/**/*',
130
-
131
- // webpack
132
- 'webpack/**',
101
+ '**/vitest.config.*',
133
102
 
134
103
  // configs
135
- '.commitlintrc.js',
136
104
  '.cz-config.js',
137
- '.jest.config.js',
105
+ '.cz-config.ts',
106
+ '.cz-config.mjs',
107
+ '.cz-config.cjs',
138
108
  '.lintstagedrc.js',
109
+ '.lintstagedrc.ts',
110
+ '.lintstagedrc.mjs',
139
111
  '.prettierrc.js',
112
+ '.prettierrc.ts',
113
+ '.prettierrc.mjs',
140
114
  '.stylelintrc.js',
115
+ '.stylelintrc.ts',
116
+ '.stylelintrc.mjs',
141
117
  'eslint.config.js',
118
+ 'eslint.config.ts',
142
119
  'eslint.config.mjs',
143
120
 
144
121
  // other
@@ -151,100 +128,237 @@ const commonRules = {
151
128
  'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
152
129
  }
153
130
 
154
- const server = [
155
- js.configs.recommended,
156
- importPlugin.flatConfigs.recommended,
131
+ const workspacesConfig = {
132
+ plugins: { workspaces },
133
+ rules: {
134
+ 'workspaces/no-relative-imports': 'error',
135
+ 'workspaces/require-dependency': 'warn',
136
+ },
137
+ }
157
138
 
158
- {
159
- files: ['**/*.{js,mjs,ts}'],
160
- languageOptions: {
161
- globals: { ...globals.node },
162
- 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
+ },
163
209
  },
164
- plugins: {
165
- 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
+ parserOptions: {
246
+ ecmaFeatures: {
247
+ jsx: true,
248
+ },
166
249
  },
167
- settings: {
168
- 'import/resolver': {
169
- typescript: {
170
- alwaysTryTypes: true,
171
- },
250
+ },
251
+ settings: {
252
+ 'import/resolver': {
253
+ typescript: {
254
+ alwaysTryTypes: true,
172
255
  },
173
- n: { tryExtensions: ['.js', '.ts'] },
174
256
  },
175
- rules: {
176
- ...commonRules,
177
- 'no-console': 'error',
178
- 'import/no-unresolved': ['error', { commonjs: true }],
257
+ react: {
258
+ version: 'detect',
179
259
  },
180
260
  },
261
+ rules: {
262
+ ...commonRules,
263
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
264
+ 'import/no-unresolved': 'error',
265
+ 'react/jsx-sort-props': [1, { ignoreCase: true }],
266
+ 'no-restricted-globals': ['error'].concat(confusingBrowserGlobals),
267
+ },
268
+ }
269
+
270
+ const clientCommonjs = {
271
+ files: ['**/*.cjs'],
272
+ languageOptions: { sourceType: 'commonjs' },
273
+ }
274
+
275
+ const server = [
276
+ js.configs.recommended,
277
+ importPlugin.flatConfigs.recommended,
278
+ pluginPromise.configs['flat/recommended'],
279
+ workspacesConfig,
280
+
281
+ serverFiles,
282
+ serverCommonjs,
283
+ serverMjs,
284
+
285
+ typescriptConfig,
286
+ viteConfig,
287
+ globalIgnores(globalIgnoreList),
288
+ ]
289
+
290
+ const client = [
291
+ js.configs.recommended,
292
+ importPlugin.flatConfigs.recommended,
293
+ pluginPromise.configs['flat/recommended'],
294
+ workspacesConfig,
295
+
296
+ react.configs.flat.recommended,
297
+ react.configs.flat['jsx-runtime'],
298
+ reactHooks.configs.flat.recommended,
299
+ jsxA11y.flatConfigs.recommended,
300
+
301
+ clientFiles,
302
+ clientCommonjs,
303
+
304
+ typescriptConfig,
305
+ viteConfig,
306
+ globalIgnores(globalIgnoreList),
307
+ ]
308
+
309
+ const root = [
310
+ js.configs.recommended,
311
+ importPlugin.flatConfigs.recommended,
312
+ pluginPromise.configs['flat/recommended'],
313
+ workspacesConfig,
314
+
315
+ serverFiles,
316
+ serverCommonjs,
317
+ serverMjs,
318
+
319
+ {
320
+ files: ['cypress/**/*.{js,mjs,ts}'],
321
+ extends: [pluginCypress.configs.recommended],
322
+ },
181
323
 
182
324
  {
183
- files: ['**/*.js'],
184
- languageOptions: {
185
- sourceType: 'commonjs',
186
- },
187
- rules: {
188
- ...nodePlugin.configs['flat/recommended-script'].rules,
189
- },
325
+ ...react.configs.flat.recommended,
326
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
190
327
  },
191
328
 
192
329
  {
193
- files: ['**/*.mjs', '**/*.ts'],
194
- languageOptions: {
195
- sourceType: 'module',
196
- },
197
- rules: {
198
- 'no-restricted-globals': [
199
- 'error',
200
- {
201
- name: '__dirname',
202
- message:
203
- 'Do not use __dirname; use import.meta.url or process.cwd().',
204
- },
205
- {
206
- name: '__filename',
207
- message:
208
- 'Do not use __filename in ES modules or TypeScript; use import.meta.url or path.resolve() instead.',
209
- },
210
- ],
211
- },
330
+ ...react.configs.flat['jsx-runtime'],
331
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
212
332
  },
213
333
 
214
334
  {
215
- files: ['**/*.mjs'],
216
- rules: {
217
- ...nodePlugin.configs['flat/recommended-module'].rules,
218
- },
335
+ ...reactHooks.configs.flat.recommended,
336
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
219
337
  },
220
338
 
221
339
  {
222
- files: ['**/*.ts'],
223
- languageOptions: {
224
- parser: tseslint.parser,
225
- },
226
- plugins: {
227
- '@typescript-eslint': tseslint.plugin,
228
- },
229
- rules: {
230
- ...tseslint.configs.recommended.rules,
231
- '@typescript-eslint/explicit-function-return-type': 'error',
232
- },
340
+ ...jsxA11y.flatConfigs.recommended,
341
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
342
+ },
343
+
344
+ {
345
+ ...clientFiles,
346
+ files: ['packages/client/**/*.{js,jsx,mjs,cjs,ts,tsx}'],
233
347
  },
234
348
 
235
- globalIgnores([
236
- '**/_build',
237
- '**/dist',
238
- '**/docs',
239
- '!**/.storybook',
240
- '!**/.commitlintrc.js',
241
- '!**/.cz-config.js',
242
- '!**/.jest.config.js',
243
- '!**/.lintstagedrc.js',
244
- '!**/.prettierrc.js',
245
- '!**/.stylelintrc.js',
246
- '**/node_modules',
247
- ]),
349
+ {
350
+ ...clientCommonjs,
351
+ files: ['packages/client/**/*.cjs'],
352
+ },
353
+
354
+ typescriptConfig,
355
+ viteConfig,
356
+ globalIgnores(globalIgnoreList),
248
357
  ]
249
358
 
250
- export { defineConfig as defineEslintConfig, server as serverEslintConfig }
359
+ export {
360
+ defineConfig as defineEslintConfig,
361
+ server as serverEslintConfig,
362
+ client as clientEslintConfig,
363
+ root as rootEslintConfig,
364
+ }
package/src/index.mjs CHANGED
@@ -1,12 +1,22 @@
1
- import commitizen from './commitizen'
2
- import { defineEslintConfig, serverEslintConfig } from './eslint.mjs'
3
- import prettier from './prettier'
4
- import stylelint from './stylelint'
5
- import lintstaged from './lintstaged'
1
+ /* eslint-disable-next-line import/extensions */
2
+ import commitizen from './commitizen.js'
3
+
4
+ import {
5
+ defineEslintConfig,
6
+ serverEslintConfig,
7
+ clientEslintConfig,
8
+ rootEslintConfig,
9
+ } from './eslint.mjs'
10
+
11
+ import prettier from './prettier.mjs'
12
+ import stylelint from './stylelint.mjs'
13
+ import lintstaged from './lintstaged.mjs'
6
14
 
7
15
  export {
8
16
  defineEslintConfig,
9
17
  serverEslintConfig,
18
+ clientEslintConfig,
19
+ rootEslintConfig,
10
20
  stylelint,
11
21
  prettier,
12
22
  commitizen,
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  '*.js': ['eslint', 'stylelint'],
3
3
  '*.{js,graphql,json,yml,md,html}': ['prettier --check'],
4
4
  }