Skip to content

Commit af4de52

Browse files
fix eslint flat config
1 parent 51db881 commit af4de52

File tree

9 files changed

+852
-1320
lines changed

9 files changed

+852
-1320
lines changed

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ ESLint rules for Primer React
66

77
## Installation
88

9-
1. Assuming you already have [ESLint](https://www.npmjs.com/package/eslint) and
10-
[Primer React](https://github.com/primer/react) installed, run:
9+
Assuming you already have [ESLint](https://www.npmjs.com/package/eslint) and [Primer React](https://github.com/primer/react) installed, run:
1110

1211
```shell
1312
npm install --save-dev eslint-plugin-primer-react
@@ -17,8 +16,29 @@ ESLint rules for Primer React
1716
yarn add --dev eslint-plugin-primer-react
1817
```
1918

20-
2. In your [ESLint configuration file](https://eslint.org/docs/user-guide/configuring/configuration-files), extend the
21-
recommended Primer React ESLint config:
19+
## Setup
20+
21+
### Flat Configuration (`eslint.config.js`)
22+
23+
In your [`eslint.config`](https://eslint.org/docs/user-guide/configuring/configuration-files) file, import `eslint-plugin-primer-react` and extend the recommended configuration using `getFlatConfigs()`:
24+
25+
```js
26+
import pluginPrimerReact from 'eslint-plugin-primer-react'
27+
28+
export default [
29+
pluginPrimerReact.getFlatConfigs().recommended,
30+
{
31+
rules: {
32+
'primer-react/no-system-props': 'error',
33+
// other custom rules...
34+
},
35+
},
36+
]
37+
```
38+
39+
### Legacy Configuration (`.eslintrc.js`)
40+
41+
In your [`.eslintrc`](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) file, extend the recommended Primer React ESLint config:
2242

2343
```js
2444
{

eslint.config.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = [
1717
},
1818
},
1919
rules: {
20-
'importPlugin/no-commonjs': 'off',
20+
'import/no-commonjs': 'off',
2121
'no-shadow': 'off',
2222
'no-unused-vars': [
2323
'error',
@@ -35,18 +35,14 @@ module.exports = [
3535
...pluginJest.environments.globals.globals,
3636
},
3737
},
38-
},
39-
{
40-
files: ['.eslint.config.js', '.markdownlint-cli2.cjs'],
4138
rules: {
42-
'filenames/match-regex': 'off',
43-
'github/filenames-match-regex': 'off',
39+
'i18n-text/no-en': 'off',
4440
},
4541
},
4642
{
47-
files: ['src/url.js', 'src/rules/new-color-css-vars.js'],
43+
files: ['.markdownlint-cli2.cjs'],
4844
rules: {
49-
'importPlugin/extensions': 'off',
45+
'github/filenames-match-regex': 'off',
5046
},
5147
},
5248
]

0 commit comments

Comments
 (0)