@newhighsco/eslint-config 5.0.0 → 5.1.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/README.md CHANGED
@@ -12,7 +12,7 @@ npm install --save-dev eslint @newhighsco/eslint-config
12
12
 
13
13
  ### Prettier
14
14
 
15
- `@newhighsco/eslint-config` should be used in conjunction with [Prettier](https://prettier.io/). See the [`@newhighsco/prettier-config` installation guide](https://github.com/newhighsco/prettier-config#installation) for more details.
15
+ `@newhighsco/eslint-config` should be used in conjunction with [Prettier](https://prettier.io/). See the [`@newhighsco/prettier-config` installation guide](../prettier-config#installation) for more details.
16
16
 
17
17
  ## Usage
18
18
  New High Score ESLint rules come bundled in `@newhighsco/eslint-config`. To enable these rules, add an `eslint.config.js` at the root of your project. See the [ESLint configuration docs](https://eslint.org/docs/user-guide/configuring) for more details.
package/eslint.config.js CHANGED
@@ -3,21 +3,22 @@ import { join } from 'node:path'
3
3
 
4
4
  import { includeIgnoreFile } from '@eslint/compat'
5
5
  import { FlatCompat } from '@eslint/eslintrc'
6
+ import json from '@eslint/json'
6
7
  import { defineConfig } from 'eslint/config'
8
+ import prettierRecommended from 'eslint-plugin-prettier/recommended'
7
9
 
8
10
  const gitignore = join(process.cwd(), '.gitignore')
9
11
  const compat = new FlatCompat()
12
+ const ignore = existsSync(gitignore)
13
+ const typescript = await import('typescript')
14
+ .then(() => true)
15
+ .catch(() => false)
10
16
 
11
17
  export default defineConfig(
12
18
  [
13
19
  ...compat.config({
14
- parserOptions: {
15
- requireConfigFile: false
16
- },
17
- env: {
18
- jest: true
19
- },
20
- extends: ['standard', 'plugin:prettier/recommended'],
20
+ parserOptions: { requireConfigFile: false },
21
+ env: { jest: true },
21
22
  ignorePatterns: ['!.github', '!.storybook'],
22
23
  plugins: ['simple-import-sort'],
23
24
  rules: {
@@ -25,16 +26,13 @@ export default defineConfig(
25
26
  'simple-import-sort/exports': 'error'
26
27
  },
27
28
  overrides: [
28
- // JSON
29
+ // Javascript
29
30
  {
30
- files: ['**/*.json'],
31
- extends: [
32
- 'plugin:json/recommended-legacy',
33
- 'plugin:prettier/recommended'
34
- ]
31
+ files: ['*.?(c|m)js'],
32
+ extends: ['standard', 'plugin:prettier/recommended']
35
33
  },
36
34
  // Typescript
37
- {
35
+ typescript && {
38
36
  files: ['*.ts?(x)'],
39
37
  extends: ['love', 'plugin:prettier/recommended'],
40
38
  parserOptions: {
@@ -43,18 +41,10 @@ export default defineConfig(
43
41
  },
44
42
  plugins: ['tsc'],
45
43
  rules: {
46
- 'tsc/config': [
47
- 'error',
48
- {
49
- configFile: './tsconfig.json'
50
- }
51
- ],
44
+ 'tsc/config': ['error', { configFile: './tsconfig.json' }],
52
45
  '@typescript-eslint/consistent-type-assertions': [
53
46
  'error',
54
- {
55
- assertionStyle: 'as',
56
- objectLiteralTypeAssertions: 'allow'
57
- }
47
+ { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
58
48
  ],
59
49
  '@typescript-eslint/no-unsafe-argument': 'off',
60
50
  '@typescript-eslint/prefer-nullish-coalescing': 'off',
@@ -64,9 +54,7 @@ export default defineConfig(
64
54
  // React
65
55
  {
66
56
  files: ['*.{js,ts,md}x'],
67
- env: {
68
- browser: true
69
- },
57
+ env: { browser: true },
70
58
  extends: [
71
59
  'standard-react',
72
60
  'standard-jsx',
@@ -86,9 +74,7 @@ export default defineConfig(
86
74
  'plugin:storybook/recommended',
87
75
  'plugin:storybook/csf-strict'
88
76
  ],
89
- rules: {
90
- 'storybook/meta-inline-properties': 'error'
91
- }
77
+ rules: { 'storybook/meta-inline-properties': 'error' }
92
78
  },
93
79
  // Testing Library
94
80
  {
@@ -102,13 +88,12 @@ export default defineConfig(
102
88
  }
103
89
  },
104
90
  // Cypress
105
- {
106
- files: ['*.cy.*'],
107
- extends: ['plugin:cypress/recommended']
108
- }
91
+ { files: ['*.cy.*'], extends: ['plugin:cypress/recommended'] }
109
92
  ]
110
93
  }),
111
- existsSync(gitignore) &&
112
- includeIgnoreFile(gitignore, 'Imported .gitignore patterns')
94
+ // JSON
95
+ { files: ['**/*.json'], plugins: { json }, language: 'json/json' },
96
+ { files: ['**/*.json'], ...prettierRecommended },
97
+ ignore && includeIgnoreFile(gitignore)
113
98
  ].filter(Boolean)
114
99
  )
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.0.0",
4
+ "version": "5.1.0",
5
5
  "author": "New High Score",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -22,6 +22,7 @@
22
22
  "files": [],
23
23
  "dependencies": {
24
24
  "@eslint/compat": "1.4.0",
25
+ "@eslint/json": "0.13.2",
25
26
  "@eslint/eslintrc": "3.3.1",
26
27
  "@typescript-eslint/eslint-plugin": "7.18.0",
27
28
  "@typescript-eslint/parser": "7.18.0",
@@ -33,7 +34,6 @@
33
34
  "eslint-formatter-junit": "8.40.0",
34
35
  "eslint-plugin-cypress": "3.6.0",
35
36
  "eslint-plugin-import": "2.32.0",
36
- "eslint-plugin-json": "4.0.1",
37
37
  "eslint-plugin-jsx-a11y": "6.10.2",
38
38
  "eslint-plugin-mdx": "3.6.2",
39
39
  "eslint-plugin-n": "17.15.1",
@@ -52,6 +52,12 @@
52
52
  },
53
53
  "peerDependencies": {
54
54
  "eslint": "9.38.0",
55
- "prettier": "3.6.2"
55
+ "prettier": "3.6.2",
56
+ "typescript": "5.9.3"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "typescript": {
60
+ "optional": true
61
+ }
56
62
  }
57
63
  }