@newhighsco/eslint-config 4.2.9 → 5.0.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.
package/README.md CHANGED
@@ -12,22 +12,24 @@ 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
- New High Score ESLint rules come bundled in `@newhighsco/eslint-config`. To enable these rules, add an `eslintConfig` property in your `package.json`. See the [ESLint configuration docs](https://eslint.org/docs/user-guide/configuring) for more details.
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.
19
19
 
20
- ```json
21
- "eslintConfig": {
22
- "extends": ["@newhighsco"]
23
- }
20
+ ```javascript
21
+ // `eslint.config.js`
22
+ import config from '@newhighsco/eslint-config'
23
+ import { defineConfig } from 'eslint/config'
24
+
25
+ export default defineConfig([{ extends: [config] }])
24
26
  ```
25
27
 
26
28
  Now you can run ESLint by adding the following scripts to your `package.json`. See the [ESLint CLI docs](https://eslint.org/docs/user-guide/command-line-interface) for more details.
27
29
 
28
30
  ```json
29
31
  "scripts": {
30
- "lint:js": "eslint --cache --ignore-path .gitignore .",
32
+ "lint:js": "eslint --cache .",
31
33
  "format:js": "yarn lint:js --fix"
32
34
  }
33
35
  ```
@@ -0,0 +1,98 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ import { includeIgnoreFile } from '@eslint/compat'
5
+ import { FlatCompat } from '@eslint/eslintrc'
6
+ import { defineConfig } from 'eslint/config'
7
+
8
+ const gitignore = join(process.cwd(), '.gitignore')
9
+ const compat = new FlatCompat()
10
+ const ignore = existsSync(gitignore)
11
+ const typescript = await import('typescript')
12
+ .then(() => true)
13
+ .catch(() => false)
14
+
15
+ export default defineConfig(
16
+ [
17
+ ...compat.config({
18
+ parserOptions: { requireConfigFile: false },
19
+ env: { jest: true },
20
+ extends: ['standard', 'plugin:prettier/recommended'],
21
+ ignorePatterns: ['!.github', '!.storybook'],
22
+ plugins: ['simple-import-sort'],
23
+ rules: {
24
+ 'simple-import-sort/imports': 'error',
25
+ 'simple-import-sort/exports': 'error'
26
+ },
27
+ overrides: [
28
+ // JSON
29
+ {
30
+ files: ['**/*.json'],
31
+ extends: [
32
+ 'plugin:json/recommended-legacy',
33
+ 'plugin:prettier/recommended'
34
+ ]
35
+ },
36
+ // Typescript
37
+ typescript && {
38
+ files: ['*.ts?(x)'],
39
+ extends: ['love', 'plugin:prettier/recommended'],
40
+ parserOptions: {
41
+ project: './tsconfig.json',
42
+ warnOnUnsupportedTypeScriptVersion: false
43
+ },
44
+ plugins: ['tsc'],
45
+ rules: {
46
+ 'tsc/config': ['error', { configFile: './tsconfig.json' }],
47
+ '@typescript-eslint/consistent-type-assertions': [
48
+ 'error',
49
+ { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
50
+ ],
51
+ '@typescript-eslint/no-unsafe-argument': 'off',
52
+ '@typescript-eslint/prefer-nullish-coalescing': 'off',
53
+ '@typescript-eslint/strict-boolean-expressions': 'off'
54
+ }
55
+ },
56
+ // React
57
+ {
58
+ files: ['*.{js,ts,md}x'],
59
+ env: { browser: true },
60
+ extends: [
61
+ 'standard-react',
62
+ 'standard-jsx',
63
+ 'plugin:prettier/recommended',
64
+ 'plugin:jsx-a11y/recommended',
65
+ 'plugin:mdx/recommended'
66
+ ],
67
+ rules: {
68
+ // Overrides standard-react
69
+ 'jsx-quotes': ['error', 'prefer-double']
70
+ }
71
+ },
72
+ // Storybook
73
+ {
74
+ files: ['*.stories.*'],
75
+ extends: [
76
+ 'plugin:storybook/recommended',
77
+ 'plugin:storybook/csf-strict'
78
+ ],
79
+ rules: { 'storybook/meta-inline-properties': 'error' }
80
+ },
81
+ // Testing Library
82
+ {
83
+ files: ['*.spec.*'],
84
+ extends: ['plugin:testing-library/react'],
85
+ rules: {
86
+ 'testing-library/no-node-access': [
87
+ 'error',
88
+ { allowContainerFirstChild: true }
89
+ ]
90
+ }
91
+ },
92
+ // Cypress
93
+ { files: ['*.cy.*'], extends: ['plugin:cypress/recommended'] }
94
+ ]
95
+ }),
96
+ ignore && includeIgnoreFile(gitignore)
97
+ ].filter(Boolean)
98
+ )
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": "4.2.9",
4
+ "version": "5.0.1",
5
5
  "author": "New High Score",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -14,12 +14,15 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/newhighsco/config/issues"
16
16
  },
17
- "main": "index.js",
17
+ "type": "module",
18
+ "main": "eslint.config.js",
18
19
  "scripts": {
19
20
  "test": "eslint --format junit --output-file ../../reports/eslint-config.xml __tests__"
20
21
  },
21
22
  "files": [],
22
23
  "dependencies": {
24
+ "@eslint/compat": "1.4.0",
25
+ "@eslint/eslintrc": "3.3.1",
23
26
  "@typescript-eslint/eslint-plugin": "7.18.0",
24
27
  "@typescript-eslint/parser": "7.18.0",
25
28
  "eslint-config-prettier": "10.1.8",
@@ -27,9 +30,10 @@
27
30
  "eslint-config-standard-jsx": "11.0.0",
28
31
  "eslint-config-standard-react": "13.0.0",
29
32
  "eslint-config-love": "44.0.0",
33
+ "eslint-formatter-junit": "8.40.0",
30
34
  "eslint-plugin-cypress": "3.6.0",
31
35
  "eslint-plugin-import": "2.32.0",
32
- "eslint-plugin-json-format": "2.0.1",
36
+ "eslint-plugin-json": "4.0.1",
33
37
  "eslint-plugin-jsx-a11y": "6.10.2",
34
38
  "eslint-plugin-mdx": "3.6.2",
35
39
  "eslint-plugin-n": "17.15.1",
@@ -44,14 +48,16 @@
44
48
  },
45
49
  "devDependencies": {
46
50
  "@types/react": "19.2.2",
47
- "eslint": "8.57.1"
51
+ "eslint": "9.38.0"
48
52
  },
49
53
  "peerDependencies": {
50
- "eslint": "8.57.1",
51
- "prettier": "3.6.2"
54
+ "eslint": "9.38.0",
55
+ "prettier": "3.6.2",
56
+ "typescript": "5.9.3"
52
57
  },
53
- "eslintConfig": {
54
- "root": true,
55
- "extends": "."
58
+ "peerDependenciesMeta": {
59
+ "typescript": {
60
+ "optional": true
61
+ }
56
62
  }
57
63
  }
package/index.js DELETED
@@ -1,96 +0,0 @@
1
- module.exports = {
2
- parserOptions: {
3
- requireConfigFile: false
4
- },
5
- env: {
6
- jest: true
7
- },
8
- extends: ['standard', 'plugin:prettier/recommended'],
9
- ignorePatterns: ['!.github', '!.storybook'],
10
- plugins: ['simple-import-sort'],
11
- rules: {
12
- 'simple-import-sort/imports': 'error',
13
- 'simple-import-sort/exports': 'error'
14
- },
15
- overrides: [
16
- // JSON
17
- {
18
- files: ['*.json'],
19
- plugins: ['json-format'],
20
- settings: {
21
- 'json/json-with-comments-files': [],
22
- 'json/sort-package-json': false
23
- }
24
- },
25
- // Typescript
26
- {
27
- files: ['*.ts?(x)'],
28
- extends: ['love', 'plugin:prettier/recommended'],
29
- parserOptions: {
30
- project: './tsconfig.json',
31
- warnOnUnsupportedTypeScriptVersion: false
32
- },
33
- plugins: ['tsc'],
34
- rules: {
35
- 'tsc/config': [
36
- 'error',
37
- {
38
- configFile: './tsconfig.json'
39
- }
40
- ],
41
- '@typescript-eslint/consistent-type-assertions': [
42
- 'error',
43
- {
44
- assertionStyle: 'as',
45
- objectLiteralTypeAssertions: 'allow'
46
- }
47
- ],
48
- '@typescript-eslint/no-unsafe-argument': 'off',
49
- '@typescript-eslint/prefer-nullish-coalescing': 'off',
50
- '@typescript-eslint/strict-boolean-expressions': 'off'
51
- }
52
- },
53
- // React
54
- {
55
- files: ['*.{js,ts,md}x'],
56
- env: {
57
- browser: true
58
- },
59
- extends: [
60
- 'standard-react',
61
- 'standard-jsx',
62
- 'plugin:prettier/recommended',
63
- 'plugin:jsx-a11y/recommended',
64
- 'plugin:mdx/recommended'
65
- ],
66
- rules: {
67
- // Overrides standard-react
68
- 'jsx-quotes': ['error', 'prefer-double']
69
- }
70
- },
71
- // Storybook
72
- {
73
- files: ['**/*.stories.*'],
74
- extends: ['plugin:storybook/recommended', 'plugin:storybook/csf-strict'],
75
- rules: {
76
- 'storybook/meta-inline-properties': 'error'
77
- }
78
- },
79
- // Testing Library
80
- {
81
- files: ['**/*.spec.*'],
82
- extends: ['plugin:testing-library/react'],
83
- rules: {
84
- 'testing-library/no-node-access': [
85
- 'error',
86
- { allowContainerFirstChild: true }
87
- ]
88
- }
89
- },
90
- // Cypress
91
- {
92
- files: ['**/*.cy.*'],
93
- extends: ['plugin:cypress/recommended']
94
- }
95
- ]
96
- }