-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ESLint extends and add Jest rules
- Loading branch information
Showing
11 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,24 @@ Then create a file named `.eslintrc.json` with following contents in the root fo | |
|
||
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc.json` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website. | ||
|
||
## Jest rules | ||
|
||
This config also ships with optional Jest rules for ESLint (based on [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest)). | ||
|
||
You'll first need to add the plugin. | ||
|
||
```sh | ||
npm install --save-dev [email protected] | ||
``` | ||
|
||
You can then enable these rules by adding the Jest config to the `extends` array in your ESLint config. | ||
|
||
```json | ||
{ | ||
"extends": ["react-app", "react-app/jest"] | ||
} | ||
``` | ||
|
||
## Accessibility Checks | ||
|
||
The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin are activated: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// We use eslint-loader so even warnings are very visible. | ||
// This is why we prefer to use "WARNING" level for potential errors, | ||
// and we try not to use "ERROR" level at all. | ||
|
||
module.exports = { | ||
plugins: ['jest'], | ||
overrides: [ | ||
{ | ||
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'], | ||
env: { | ||
'jest/globals': true, | ||
}, | ||
// A subset of the recommended rules: | ||
// https://github.com/jest-community/eslint-plugin-jest#rules | ||
rules: { | ||
'jest/expect-expect': 'warn', | ||
'jest/no-identical-title': 'warn', | ||
'jest/valid-describe': 'warn', | ||
'jest/valid-expect': 'warn', | ||
'jest/valid-expect-in-promise': 'warn', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters