Skip to content

Commit 1d4c7c7

Browse files
authored
feat: add browser configs (#57)
1 parent d76bd7a commit 1d4c7c7

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ If you're creating a new repository, you can use the
1414
[following GitHub template](https://github.com/netlify/node-template). Otherwise, please follow those steps:
1515

1616
- `npm install -D @netlify/eslint-config-node`
17-
- Add the following `.eslintrc.js` to the root of the project. Individual `rules` and `overrides` can be tweaked for the
18-
specific project.
17+
- Add a `.eslintrc.js` file to the root of the project. Based on the type of the project update the content of the file:
18+
19+
### Node.js project
1920

2021
```js
2122
const { overrides } = require('@netlify/eslint-config-node')
@@ -27,6 +28,32 @@ module.exports = {
2728
}
2829
```
2930

31+
### React application
32+
33+
```js
34+
const { overrides } = require('@netlify/eslint-config-node/react_config')
35+
36+
module.exports = {
37+
extends: '@netlify/eslint-config-node/react_config',
38+
rules: {},
39+
overrides: [...overrides],
40+
}
41+
```
42+
43+
### Vanilla JS in HTML files
44+
45+
```js
46+
const { overrides } = require('@netlify/eslint-config-node/vanilla_js_config')
47+
48+
module.exports = {
49+
extends: '@netlify/eslint-config-node/vanilla_js_config',
50+
rules: {},
51+
overrides: [...overrides],
52+
}
53+
```
54+
55+
>Individual `rules` and `overrides` can be tweaked for the specific project.
56+
3057
- Add the following `.prettierrc.json` to the root of the project:
3158

3259
```json

react_config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { overrides } = require('./.eslintrc.js')
2+
3+
const ECMA_VERSION = 6
4+
5+
module.exports = {
6+
extends: './.eslintrc.js',
7+
overrides: [
8+
...overrides,
9+
{
10+
files: ['*.jsx'],
11+
parserOptions: {
12+
ecmaVersion: ECMA_VERSION,
13+
sourceType: 'module',
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
},
18+
env: {
19+
browser: true,
20+
},
21+
extends: ['eslint:recommended', 'plugin:react/recommended'],
22+
rules: {
23+
'unicorn/filename-case': 0,
24+
'node/no-unsupported-features/es-syntax': 0,
25+
},
26+
},
27+
],
28+
}

vanilla_js_config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { overrides } = require('./.eslintrc.js')
2+
3+
module.exports = {
4+
extends: './.eslintrc.js',
5+
overrides: [
6+
...overrides,
7+
{
8+
files: ['*.html'],
9+
env: {
10+
browser: true,
11+
},
12+
extends: ['eslint:recommended'],
13+
},
14+
],
15+
}

0 commit comments

Comments
 (0)