@newhighsco/eslint-config 5.3.0 → 5.4.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.
Files changed (2) hide show
  1. package/eslint.config.js +102 -82
  2. package/package.json +3 -3
package/eslint.config.js CHANGED
@@ -7,95 +7,115 @@ import json from '@eslint/json'
7
7
  import { defineConfig } from 'eslint/config'
8
8
  import cypress from 'eslint-plugin-cypress'
9
9
  import prettierRecommended from 'eslint-plugin-prettier/recommended'
10
+ import simpleImportSort from 'eslint-plugin-simple-import-sort'
10
11
  import testingLibrary from 'eslint-plugin-testing-library'
12
+ import globals from 'globals'
11
13
 
12
- const gitignore = join(process.cwd(), '.gitignore')
13
- const compat = new FlatCompat()
14
- const ignore = existsSync(gitignore)
14
+ const existsDependency = async name =>
15
+ await import(name).then(() => true).catch(() => false)
15
16
 
16
- const hasDependency = async dependency =>
17
- await import(dependency).then(() => true).catch(() => false)
17
+ const optionalDependency = async name =>
18
+ await import(name)
19
+ .then(({ default: plugin }) => plugin)
20
+ .catch(() => undefined)
18
21
 
19
- export default defineConfig(
20
- [
21
- ...compat.config({
22
- parserOptions: { requireConfigFile: false },
23
- env: { jest: true },
24
- ignorePatterns: ['!.github', '!.storybook'],
25
- plugins: ['simple-import-sort'],
26
- rules: {
27
- 'simple-import-sort/imports': 'error',
28
- 'simple-import-sort/exports': 'error'
29
- },
30
- overrides: [
31
- // Javascript
32
- {
33
- files: ['*.?(c|m)js'],
34
- extends: ['standard', 'plugin:prettier/recommended']
35
- },
36
- // Typescript
37
- (await hasDependency('typescript')) && {
38
- files: ['*.ts?(x)'],
39
- extends: ['love', 'plugin:prettier/recommended'],
40
- parserOptions: {
41
- project: './tsconfig.json',
42
- warnOnUnsupportedTypeScriptVersion: false
43
- },
44
- rules: {
45
- '@typescript-eslint/consistent-type-assertions': [
46
- 'error',
47
- { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
48
- ],
49
- '@typescript-eslint/no-unsafe-argument': 'off',
50
- '@typescript-eslint/prefer-nullish-coalescing': 'off',
51
- '@typescript-eslint/strict-boolean-expressions': 'off'
52
- }
53
- },
54
- // React
55
- {
56
- files: ['*.{js,ts,md}x'],
57
- env: { browser: true },
58
- extends: [
59
- 'standard-react',
60
- 'standard-jsx',
61
- 'plugin:prettier/recommended',
62
- 'plugin:jsx-a11y/recommended',
63
- 'plugin:mdx/recommended'
64
- ],
65
- rules: {
66
- // Overrides standard-react
67
- 'jsx-quotes': ['error', 'prefer-double']
68
- }
69
- },
70
- // Storybook
71
- (await hasDependency('storybook')) && {
72
- files: ['*.stories.*'],
73
- extends: [
74
- 'plugin:storybook/recommended',
75
- 'plugin:storybook/csf-strict'
76
- ],
77
- rules: { 'storybook/meta-inline-properties': 'error' }
78
- }
79
- ].filter(Boolean)
80
- }),
81
- // JSON
82
- { files: ['**/*.json'], plugins: { json }, language: 'json/json' },
83
- { files: ['**/*.json'], ...prettierRecommended },
84
- // Testing Library
22
+ const legacy = new FlatCompat().config({
23
+ overrides: [
24
+ // Javascript
85
25
  {
86
- files: ['**/*.spec.*'],
87
- ignores: ['**/*.spec.?(s)css'],
88
- ...testingLibrary.configs['flat/react'],
26
+ files: ['*.?(c|m)js'],
27
+ extends: ['standard', 'plugin:prettier/recommended']
28
+ },
29
+ // Typescript
30
+ (await existsDependency('typescript')) && {
31
+ files: ['*.ts?(x)'],
32
+ extends: ['love', 'plugin:prettier/recommended'],
33
+ parserOptions: {
34
+ project: './tsconfig.json',
35
+ warnOnUnsupportedTypeScriptVersion: false
36
+ },
89
37
  rules: {
90
- ...testingLibrary.configs['flat/react'].rules,
91
- 'testing-library/no-node-access': [
38
+ '@typescript-eslint/consistent-type-assertions': [
92
39
  'error',
93
- { allowContainerFirstChild: true }
94
- ]
40
+ { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
41
+ ],
42
+ '@typescript-eslint/no-unsafe-argument': 'off',
43
+ '@typescript-eslint/prefer-nullish-coalescing': 'off',
44
+ '@typescript-eslint/strict-boolean-expressions': 'off'
95
45
  }
96
46
  },
97
- // Cypress
98
- { files: ['**/*.cy.*'], extends: [cypress.configs.recommended] },
99
- ignore && includeIgnoreFile(gitignore)
47
+ // React
48
+ {
49
+ files: ['*.{js,ts,md}x'],
50
+ env: { browser: true },
51
+ extends: [
52
+ 'standard-react',
53
+ 'standard-jsx',
54
+ 'plugin:prettier/recommended',
55
+ 'plugin:jsx-a11y/recommended',
56
+ 'plugin:mdx/recommended'
57
+ ],
58
+ rules: {
59
+ // Overrides standard-react
60
+ 'jsx-quotes': ['error', 'prefer-double']
61
+ }
62
+ }
100
63
  ].filter(Boolean)
101
- )
64
+ })
65
+
66
+ // console.log(111, JSON.stringify(legacy, null, 2))
67
+
68
+ const configs = [
69
+ {
70
+ ignores: ['!.github', '!.storybook'],
71
+ languageOptions: { globals: { ...globals.jest } },
72
+ plugins: { 'simple-import-sort': simpleImportSort },
73
+ rules: {
74
+ 'simple-import-sort/imports': 'error',
75
+ 'simple-import-sort/exports': 'error'
76
+ }
77
+ },
78
+ ...legacy,
79
+ // JSON
80
+ { files: ['**/*.json'], plugins: { json }, language: 'json/json' },
81
+ { files: ['**/*.json'], ...prettierRecommended },
82
+ { files: ['**/+(j|t)sconfig?(.*).json'], language: 'json/jsonc' },
83
+ // Testing Library
84
+ {
85
+ files: ['**/*.spec.*'],
86
+ ignores: ['**/*.spec.?(s)css'],
87
+ ...testingLibrary.configs['flat/react'],
88
+ rules: {
89
+ ...testingLibrary.configs['flat/react'].rules,
90
+ 'testing-library/no-node-access': [
91
+ 'error',
92
+ { allowContainerFirstChild: true }
93
+ ]
94
+ }
95
+ },
96
+ // Cypress
97
+ { files: ['**/*.cy.*'], extends: [cypress.configs.recommended] }
98
+ ]
99
+
100
+ // Storybook
101
+ if (await existsDependency('storybook')) {
102
+ const storybook = await optionalDependency('eslint-plugin-storybook')
103
+
104
+ configs.push(
105
+ ...storybook.configs['flat/recommended'],
106
+ ...storybook.configs['flat/csf-strict'],
107
+ {
108
+ files: ['**/*.stories.*'],
109
+ rules: { 'storybook/meta-inline-properties': 'error' }
110
+ }
111
+ )
112
+ }
113
+
114
+ // .gitignore
115
+ const gitignore = join(process.cwd(), '.gitignore')
116
+
117
+ if (existsSync(gitignore)) {
118
+ configs.push(includeIgnoreFile(gitignore))
119
+ }
120
+
121
+ export default defineConfig(configs)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@newhighsco/eslint-config",
3
3
  "description": "New High Score shareable config for ESLint",
4
- "version": "5.3.0",
4
+ "version": "5.4.1",
5
5
  "author": "New High Score",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -43,10 +43,10 @@
43
43
  "eslint-plugin-react-hooks": "7.0.1",
44
44
  "eslint-plugin-simple-import-sort": "12.1.1",
45
45
  "eslint-plugin-storybook": "9.1.16",
46
- "eslint-plugin-testing-library": "7.13.3"
46
+ "eslint-plugin-testing-library": "7.13.4"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/react": "19.2.2",
49
+ "@types/react": "19.2.4",
50
50
  "eslint": "9.39.1"
51
51
  },
52
52
  "peerDependencies": {