Comments (6)
I've updated the patterns. I've removed .jsx
support because it's a bad practice.
from eslint-config.
Actually this should be opt-in and not the default. Perhaps a different addon?
from eslint-config.
@satazor @andregoncalvesdev @AfonsoVReis
According to ESLint's docs, the configuration can be modified under overrides
key in .eslintrc.*
. I have been experimenting a bit and below is the best I've achieved so far.
- I had to make the the top-level
.eslintrc.json
into.eslintrc.js
instead:
module.exports = {
'root': true,
'extends': [
'./es5.js',
'./addons/node.js',
'./addons/jest.js',
],
'rules': {
'quote-props': [2, 'always'],
},
'overrides': [require('./addons/overrides/jest-test-dir')],
};
where jest-test-dir.js
is:
'use strict';
module.exports = {
'env': {
'jest/globals': false,
},
'files': ['!test/**/*.js'],
'rules': {
'jest/no-disabled-tests': 0,
'jest/no-focused-tests': 0,
'jest/no-identical-title': 0,
'jest/valid-expect': 0,
},
};
The above works just fine, but has the following downsides/problems:
- The ESLint config must be
.js
instead of.json
, if we wish to use the override as a module - ESLint is not seeing changes made to
jest-test-dir.js
probably because we're usingrequire
, which is an inconvenient. I do not yet know how to fix this.
Feedback is welcome!
from eslint-config.
I think I got it. I was not aware that it was possible to extend a config with overrides
:
// ./addons/overrides/jest-test-files.js`
'use strict';
module.exports = {
'overrides': [{
'env': {
'jest/globals': false,
},
'files': ['!test/**/*.js'],
'rules': {
'jest/no-disabled-tests': 0,
'jest/no-focused-tests': 0,
'jest/no-identical-title': 0,
'jest/valid-expect': 0,
},
}],
};
// ./.eslintrc.json
{
"root": true,
"extends": [
"./es5.js",
"./addons/node.js",
"./addons/jest.js",
"./addons/overrides/jest-test-dir.js"
],
"rules": {
"quote-props": [2, "always"]
}
}
What do you think?
from eslint-config.
I think we do not need to create jest-test-dir
but put all of this in the addons/jest.js
.
Regarding the files
it should be based on the default patterns of jest + add a test
folder because of utilities I mentioned above.
[
'!**/__tests__/**/*.js',
'!**/?(*.)(spec|test).js',
'!test/**/*.js',
]
from eslint-config.
@satazor thanks!
It is working already. I'm just finalizing the tests. I'll open a PR shortly.
from eslint-config.
Related Issues (20)
- Consider using `eslint-plugin-testing-library` and `eslint-plugin-jest-dom` HOT 2
- Update `eslint-plugin-jsx-a11y` to v6.3.1 HOT 1
- Enforce lowercase in test names
- Consider enabling linting of markdown files HOT 1
- Remove rules no longer needed in React 17
- Support ESM for Node.js
- Consider using `eslint-plugin-postcss-modules`
- Consider laxing `max-len` HOT 1
- Disable `global-require` and `prefer-import` on the jest addon HOT 1
- Upgrade to eslint@5 HOT 1
- Specify react version HOT 1
- Consider using eslint-plugin-jsx-a11y HOT 3
- An in-range update of eslint-plugin-jsdoc is breaking the build 🚨 HOT 10
- An in-range update of eslint is breaking the build 🚨 HOT 2
- Reminder: after update to ESLint v6, dissalow 'allow require for configs' for nested configs HOT 1
- Re-evaluate our `indent` rule exceptions HOT 15
- Disable some react rules in tests HOT 3
- jest global throws 'not defined' error in global mock HOT 2
- Remove commitHooks setting from Lerna's publish config
- Add Node CI with GitHub Actions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-config.