Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5b87a0

Browse files
better README
1 parent 60f1103 commit e5b87a0

File tree

4 files changed

+102
-57
lines changed

4 files changed

+102
-57
lines changed

‎.prettierrc.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ module.exports = {
33
tabWidth: 2,
44
singleQuote: true,
55
trailingComma: 'none',
6-
parser: 'babel',
76
overrides: [
7+
{
8+
files: ['*.js', '*.jsx'],
9+
options: {
10+
parser: 'babel'
11+
}
12+
},
813
{
914
files: ['*.ts', '*.tsx'],
1015
options: {
@@ -14,6 +19,10 @@ module.exports = {
1419
{
1520
files: ['*.json', '*.jsonc', '.*rc'],
1621
options: { parser: 'json' }
22+
},
23+
{
24+
files: ['*.css', '*.scss', '.*less'],
25+
options: { parser: 'css' }
1726
}
1827
]
1928
};

‎README.md‎

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,58 @@
1-
# @fieryeagle/eslint-config-react
2-
3-
Common eslint + prettier config for React that comes with most dependencies and a patch package to allow minimal setup in userland.
4-
5-
## Usage
6-
7-
- add packages `yarn add -D @fieryeagle/eslint-config-react @rushstack/eslint-patch`
8-
- create .eslintrc.js
9-
10-
```
11-
require("@rushstack/eslint-patch/modern-module-resolution");
12-
module.exports = {
13-
extends: ['@cheshirecode/eslint-config-react'],
14-
parserOptions: { tsconfigRootDir: __dirname }
15-
};
16-
```
17-
- create .prettier.js
18-
```
19-
const prettierConfig = require('@fieryeagle/eslint-config-react/.prettierrc');
20-
21-
module.exports = prettierConfig;const prettierConfig = require('@fieryeagle/eslint-config-react/.prettierrc.js');
22-
23-
module.exports = prettierConfig;
1+
# @fieryeagle/eslint-config-react
2+
3+
Common eslint + prettier config for React that comes with most dependencies and a patch package to allow minimal setup in userland.
4+
5+
## Why?
6+
7+
Initial setup of linting and formatting get repeated over and over across codebases and teams, wasting alot of time and maintenance with duplicated then diverged configs. This package brings together:
8+
- [eslint-config-react-app](https://github.com/facebook/create-react-app/tree/main/packages/eslint-config-react-app)
9+
- [@typescript-eslint/parser](https://typescript-eslint.io/docs/linting/)
10+
- [eslint-plugin-prettier](https://github.com/prettier/eslint-config-prettier)
11+
12+
to reduces package.json clutter from
13+
```
14+
"@typescript-eslint/eslint-plugin": "^5",
15+
"@typescript-eslint/parser": "^5",
16+
"babel-eslint": "^10.1.0",
17+
"eslint": "^7.12.0",
18+
"eslint-config-prettier": "^8.3.0",
19+
"eslint-config-react-app": "^6.0.0",
20+
"eslint-plugin-flowtype": "^5.2.0",
21+
"eslint-plugin-import": "^2.24.2",
22+
"eslint-plugin-jsx-a11y": "^6.4.1",
23+
"eslint-plugin-prettier": "^4.0.0",
24+
"eslint-plugin-react": "^7.26.1",
25+
"eslint-plugin-react-hooks": "^4.2.0",
26+
"prettier": "^2.6.2",
27+
"typescript": "^4.6.4"
28+
```
29+
to
30+
```
31+
"@fieryeagle/eslint-config-react": "^0.0.5",
32+
"@rushstack/eslint-patch": "^1.1.3",
33+
```
34+
and simplifies config down to few lines of code ([example](#usage)). This is possible thanks to the workaround provided by [@rushstack/eslint-patch](https://www.npmjs.com/package/@rushstack/eslint-patch)
35+
```
36+
This patch is a workaround for a longstanding ESLint feature request that would allow a shared ESLint config to bring along its own plugins, rather than imposing peer dependencies on every consumer of the config. In a monorepo scenario, this enables your lint setup to be consolidated in a single NPM package. Doing so greatly reduces the copy+pasting and version management for all the other projects that use your standard lint rule set, but don't want to be bothered with the details.
37+
```
38+
39+
## Usage
40+
41+
- add packages `yarn add -D @fieryeagle/eslint-config-react @rushstack/eslint-patch`
42+
- create .eslintrc.js
43+
44+
```
45+
require("@rushstack/eslint-patch/modern-module-resolution");
46+
module.exports = {
47+
extends: ['@cheshirecode/eslint-config-react'],
48+
parserOptions: { tsconfigRootDir: __dirname }
49+
};
50+
```
51+
- create .prettier.js
52+
```
53+
const prettierConfig = require('@fieryeagle/eslint-config-react/.prettierrc');
54+
55+
module.exports = prettierConfig;const prettierConfig = require('@fieryeagle/eslint-config-react/.prettierrc.js');
56+
57+
module.exports = prettierConfig;
2458
```

‎index.js‎

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
module.exports = {
2-
root: true,
3-
parser: '@typescript-eslint/parser',
4-
parserOptions: {
5-
ecmaVersion: 10,
6-
ecmaFeatures: {
7-
jsx: true,
8-
},
9-
tsconfigRootDir: __dirname
10-
},
11-
env: {
12-
browser: true,
13-
jest: true,
14-
},
15-
plugins: ['prettier', 'react', '@typescript-eslint', 'jsx-a11y'],
16-
extends: [
17-
'eslint:recommended',
18-
'plugin:@typescript-eslint/recommended',
19-
'plugin:import/recommended',
20-
'plugin:import/typescript',
21-
'prettier',
22-
'react-app',
23-
],
24-
rules: {
25-
'prettier/prettier': 'error',
26-
'no-unreachable': 'error',
27-
'no-console': 'error',
28-
},
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 'latest',
6+
ecmaFeatures: {
7+
jsx: true
8+
},
9+
tsconfigRootDir: __dirname
10+
},
11+
env: {
12+
browser: true,
13+
'shared-node-browser': true
14+
},
15+
plugins: ['prettier', 'react', '@typescript-eslint', 'jsx-a11y'],
16+
extends: [
17+
'eslint:recommended',
18+
'plugin:@typescript-eslint/recommended',
19+
'plugin:import/recommended',
20+
'plugin:import/typescript',
21+
'prettier',
22+
'react-app'
23+
],
24+
rules: {
25+
'prettier/prettier': 'error',
26+
'no-unreachable': 'error',
27+
'no-console': 'error'
28+
},
29+
settings: {
30+
react: {
31+
version: 'detect'
32+
}
33+
}
2934
};

‎package.json‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
"name": "@fieryeagle/eslint-config-react",
33
"version": "0.0.5",
44
"main": "index.js",
5-
"files": [
6-
"index.js",
7-
".prettierrc.js"
8-
],
5+
"files": ["index.js", ".prettierrc.js"],
96
"repository": {
107
"type": "git",
118
"url": "git+https://github.com/cheshirecode/eslint-config-react.git"
@@ -42,5 +39,5 @@
4239
"url": "https://github.com/cheshirecode/eslint-config-react/issues"
4340
},
4441
"homepage": "https://github.com/cheshirecode/eslint-config-react#readme",
45-
"description": "common eslint + prettier config for React used by cheshireCode"
42+
"description": "common eslint + prettier config for React with workaround for its own dependencies"
4643
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /