eslint-config-acme 1.0.2 → 1.3.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 +70 -21
- package/index.js +7 -1
- package/lib/base.js +6 -0
- package/package.json +13 -10
package/README.md
CHANGED
|
@@ -27,14 +27,17 @@ This will install the shared config, as well as its peer dependencies:
|
|
|
27
27
|
- eslint
|
|
28
28
|
- eslint-config-airbnb
|
|
29
29
|
- eslint-config-prettier
|
|
30
|
+
- eslint-import-resolver-alias
|
|
30
31
|
- eslint-plugin-import
|
|
31
32
|
- eslint-plugin-jsx-a11y
|
|
32
33
|
- eslint-plugin-prettier
|
|
33
34
|
- eslint-plugin-react
|
|
34
35
|
- eslint-plugin-react-hooks
|
|
36
|
+
- eslint-plugin-simple-import-sort
|
|
35
37
|
- prettier
|
|
38
|
+
- prettier-plugin-tailwindcss
|
|
36
39
|
|
|
37
|
-
**NOTE:** if you are on
|
|
40
|
+
**NOTE:** if you are on NPM <7, you will need to install these manually:
|
|
38
41
|
|
|
39
42
|
```shell
|
|
40
43
|
$ npx install-peerdeps -D eslint-config-acme
|
|
@@ -62,6 +65,52 @@ or the `.eslintrc` file:
|
|
|
62
65
|
}
|
|
63
66
|
```
|
|
64
67
|
|
|
68
|
+
## Import Alias
|
|
69
|
+
|
|
70
|
+
This config provides a default import alias resolver for `eslint-plugin-import` to support shorthand imports of local modules:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"import/resolver": {
|
|
75
|
+
"alias": {
|
|
76
|
+
"map": [["@", "./src"]],
|
|
77
|
+
"extensions": [".js", ".jsx"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This will allow you to write imports like this anywhere in your code:
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
import Foo from '@/components/foo';
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
instead of relative paths:
|
|
90
|
+
|
|
91
|
+
```jsx
|
|
92
|
+
import Foo from '../../components/foo';
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
when using [absolute imports and module path aliases](https://nextjs.org/docs/advanced-features/module-path-aliases) in **Next.js**.
|
|
96
|
+
|
|
97
|
+
This can also be overriden in your local `.eslintrc` file, if needed:
|
|
98
|
+
|
|
99
|
+
```jsx
|
|
100
|
+
// .eslintrc
|
|
101
|
+
{
|
|
102
|
+
"extends": ["acme"],
|
|
103
|
+
"settings": {
|
|
104
|
+
"import/resolver": {
|
|
105
|
+
"alias": {
|
|
106
|
+
"map": [["@", "./lib"]],
|
|
107
|
+
"extensions": [".js"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
65
114
|
## Prettier
|
|
66
115
|
|
|
67
116
|
This config supports Prettier integration out of the box. Rules that may conflict with ESLint are disabled via recommended configuration in [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier).
|
|
@@ -71,12 +120,12 @@ If you wish to override any [Prettier options](https://prettier.io/docs/en/optio
|
|
|
71
120
|
```jsx
|
|
72
121
|
// .eslintrc
|
|
73
122
|
{
|
|
74
|
-
"extends": "@acme",
|
|
123
|
+
"extends": ["@acme"],
|
|
75
124
|
"rules": {
|
|
76
125
|
"prettier/prettier": [
|
|
77
126
|
"error",
|
|
78
127
|
{
|
|
79
|
-
"printWidth":
|
|
128
|
+
"printWidth": 90
|
|
80
129
|
}
|
|
81
130
|
]
|
|
82
131
|
}
|
|
@@ -90,20 +139,22 @@ Make sure that these rules match the options specified in your `.prettierrc` fil
|
|
|
90
139
|
Add the following to your `package.json` file to define a script that will lint all known files and output the results:
|
|
91
140
|
|
|
92
141
|
```jsx
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
|
|
142
|
+
// package.json
|
|
143
|
+
{
|
|
144
|
+
"scripts": {
|
|
145
|
+
"lint": "eslint --ignore-path .gitignore ."
|
|
146
|
+
}
|
|
97
147
|
}
|
|
98
148
|
```
|
|
99
149
|
|
|
100
150
|
To fix all automatically-fixable issues, you can add the following script to your `package.json` as well (in addition to above):
|
|
101
151
|
|
|
102
152
|
```jsx
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
153
|
+
// package.json
|
|
154
|
+
{
|
|
155
|
+
"scripts": {
|
|
156
|
+
"lint:fix": "eslint --ignore-path .gitignore --fix ."
|
|
157
|
+
}
|
|
107
158
|
}
|
|
108
159
|
```
|
|
109
160
|
|
|
@@ -115,18 +166,16 @@ There is a [known issue](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/is
|
|
|
115
166
|
|
|
116
167
|
Because of this, the [standard usage](https://nextjs.org/docs/api-reference/next/link) of Next.js `<Link>` component will result in an error for the `jsx-a11y/anchor-is-valid` rule. Until the Next.js API can be updated to a more standard pattern, `eslint-config-acme` overrides this rule as suggested in [this issue](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/402#issuecomment-368305051):
|
|
117
168
|
|
|
118
|
-
```
|
|
169
|
+
```json
|
|
119
170
|
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'error',
|
|
171
|
+
"jsx-a11y/anchor-is-valid": [
|
|
172
|
+
"error",
|
|
123
173
|
{
|
|
124
|
-
components: [
|
|
125
|
-
specialLink: [
|
|
126
|
-
aspects: [
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
// ...
|
|
174
|
+
"components": ["Link"],
|
|
175
|
+
"specialLink": ["hrefLeft", "hrefRight"],
|
|
176
|
+
"aspects": ["invalidHref", "preferButton"]
|
|
177
|
+
}
|
|
178
|
+
]
|
|
130
179
|
}
|
|
131
180
|
```
|
|
132
181
|
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
jsx: true,
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
-
plugins: ['simple-import-sort', 'import'],
|
|
21
|
+
plugins: ['simple-import-sort', 'import', 'tailwindcss'],
|
|
22
22
|
rules: {
|
|
23
23
|
...base,
|
|
24
24
|
...next,
|
|
@@ -29,5 +29,11 @@ module.exports = {
|
|
|
29
29
|
// Tells eslint-plugin-react to automatically detect the version of React to use
|
|
30
30
|
version: 'detect',
|
|
31
31
|
},
|
|
32
|
+
'import/resolver': {
|
|
33
|
+
alias: {
|
|
34
|
+
map: [['@', './src']],
|
|
35
|
+
extensions: ['.js', '.jsx'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
32
38
|
},
|
|
33
39
|
};
|
package/lib/base.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-acme",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "ESLint + Prettier config for React (Next.js)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,16 +14,19 @@
|
|
|
14
14
|
"lint:fix": "eslint --fix"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"eslint": "^
|
|
18
|
-
"eslint-config-airbnb": "^
|
|
19
|
-
"eslint-config-prettier": "^8.
|
|
20
|
-
"eslint-
|
|
21
|
-
"eslint-plugin-
|
|
22
|
-
"eslint-plugin-
|
|
23
|
-
"eslint-plugin-
|
|
24
|
-
"eslint-plugin-react
|
|
17
|
+
"eslint": "^8.13.0",
|
|
18
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
19
|
+
"eslint-config-prettier": "^8.5.0",
|
|
20
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
21
|
+
"eslint-plugin-import": "^2.26.0",
|
|
22
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
23
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
24
|
+
"eslint-plugin-react": "^7.29.4",
|
|
25
|
+
"eslint-plugin-react-hooks": "^4.4.0",
|
|
25
26
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
26
|
-
"
|
|
27
|
+
"eslint-plugin-tailwindcss": "^3.5.0",
|
|
28
|
+
"prettier": "^2.6.2",
|
|
29
|
+
"prettier-plugin-tailwindcss": "^0.1.8"
|
|
27
30
|
},
|
|
28
31
|
"keywords": [
|
|
29
32
|
"config",
|