You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-2Lines changed: 56 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,53 @@ We do not include linting for Vue out of the box. Have a look at the [eslint-plu
136
136
137
137
This config is [Prettier](https://prettier.io/)-compatible, there isn’t anything extra needed.
138
138
139
+
### pre-commit
140
+
141
+
The [pre-commit](https://pre-commit.com/) pre-commit hook framework doesn’t work well with ESLint. There are three major points to set up correctly:
142
+
143
+
- Peer dependencies aren’t automatically installed like in other npm v7+ environment. We need to tell pre-commit what to install via its `additional_dependencies` configuration.
144
+
- Dependency versions aren’t locked. Always pin exact versions in the configuration to have as stable of an installation as possible.
145
+
- By default, the ESLint hook will only run `.js` files. Make sure to override its `types` attribute as well as `files` with the correct extensions (TypeScript, Vue).
146
+
147
+
Here is a sample setup with our recommended configuration:
By default, this config uses ESLint’s built-in parser, which doesn’t support [experimental ECMAScript features](https://github.com/eslint/eslint/blob/a675c89573836adaf108a932696b061946abf1e6/README.md#what-about-experimental-features). If your code uses experimental syntax with Babel, make sure to set the ESLint parser to [babel-eslint](https://github.com/babel/babel-eslint):
@@ -154,12 +201,19 @@ module.exports = {
154
201
This configuration strikes a balance between ease of use for users, and ease of maintenance.
155
202
156
203
- We use the same React-aware configuration everywhere, even non-React projects.
157
-
- We use a separate TypeScript configuration file only due to its experimental nature.
158
204
- There is a single package with a single set of dependencies.
159
205
160
206
The base configuration is kept very simple, extending from the Airbnb configuration, with Prettier compatibility and more permissive rules.
161
207
162
-
The TypeScript configuration does not rely on type checking, so it can also be used for JavaScript projects. This will eventually allow us to have a single configuration file for all projects, once the TypeScript support is no longer deemed experimental.
208
+
### TypeScript support
209
+
210
+
We use a separate TypeScript configuration file only due to its experimental nature. The TypeScript configuration does not rely on type checking, so it can also be used for JavaScript projects.
211
+
212
+
In the future, we may decide to use TypeScript for the default configuration, and have a separate configuration file for vanilla JS projects. Or document how to use the TypeScript configuration on vanilla projects (resetting the `parser` should be the only necessary change).
213
+
214
+
### Dependencies as peerDependencies
215
+
216
+
Most of the configuration’s dependencies are specified as `peerDependencies`. This is necessary due to how ESLint configurations resolve their dependencies – see [Support having plugins as dependencies in shareable config #3458](https://github.com/eslint/eslint/issues/3458). This will be changed in a future version of ESLint.
0 commit comments