-
Notifications
You must be signed in to change notification settings - Fork 1
📝 Enumerating eslint rules + package refactoring #1
Changes from all commits
6dadda9
3b8aebd
47be9e6
ae27671
8ca9190
2690ec8
ceb1ea9
3ec2407
89851ab
4de8271
a0ef622
f28d851
8226d7e
a95dd2a
649efcf
fb65164
37afb4a
a9bebb4
72a3ab1
5e7d41b
2cb604d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["./index.js"], | ||
"rules": { | ||
"no-magic-numbers": 0 // because rules are 0, 1, 2 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
node_modules | ||
node_modules | ||
npm-debug.log | ||
yarn-error.log | ||
yarn.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.editorconfig | ||
.gitignore | ||
.travis.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,95 @@ | ||
# eslint-config-casumo | ||
Holds Casumo's base JS .eslintrc as an extensible shared config | ||
<h1 align="center">eslint-config-casumo</h1> | ||
|
||
## Install | ||
<p align="center"> | ||
<a title='npm version' href="https://www.npmjs.com/package/eslint-config-casumo"> | ||
<img src='https://img.shields.io/npm/v/eslint-config-casumo.svg?style=flat-square' /> | ||
</a> | ||
<a title='MIT License' href="https://opensource.org/licenses/MIT"> | ||
<img src='https://img.shields.io/npm/l/eslint-config-casumo.svg?style=flat-square' /> | ||
</a> | ||
<a title='Downloads' href='http://npm-stat.com/charts.html?package=eslint-config-casumo&from=2015-08-01'> | ||
<img src='https://img.shields.io/npm/dm/eslint-config-casumo.svg?style=flat-square' /> | ||
</a> | ||
<a title='Commitizen friendly' href='http://commitizen.github.io/cz-cli/'> | ||
<img src='https://img.shields.io/badge/commitizen-friendly-brightgreen.svg' /> | ||
</a> | ||
</p> | ||
|
||
<h4 align="center"> | ||
ESLint shareable config for the Casumo JavaScript code style | ||
</h4> | ||
|
||
*** | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install eslint-config-casumo | ||
npm install --save-dev eslint-config-casumo | ||
``` | ||
|
||
## Usage | ||
Add the following to your `.eslintrc` file: | ||
```javascript | ||
Once the `eslint-config-casumo` package is installed, you can use it by specifying `casumo` in the [`extends`](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) section of your [ESLint configuration](http://eslint.org/docs/user-guide/configuring). | ||
|
||
```js | ||
{ | ||
"extends": "eslint-config-casumo" | ||
"extends": "casumo", | ||
"rules": { | ||
// Additional, per-project rules... | ||
} | ||
} | ||
``` | ||
``` | ||
|
||
_Note: We omitted the `eslint-config-` prefix since it is automatically assumed by ESLint._ | ||
|
||
You can override settings from the shareable config by adding them directly into your `.eslintrc` file. | ||
|
||
### Configuration structure | ||
- `casumo/rules/...` - grouping for rules by category (f.ex `eslint`, `mocha`, etc.) | ||
- Each group ideally would have `on/off.js` configurations files which will be used for composing presets | ||
- `causmo/configuration/...` - composition of rules into 'presets' | ||
|
||
#### Why `on.js` and `off.js`? | ||
The idea is to always ship a complete list of ESLint rules and explicitly turn off rule groups which are not needed. This is mostly useful for when `eslint-find-rules` runs. In case any new rule is added the plugin will call out the missing rule. | ||
|
||
For example if we want to completely ignore `ecma-script-6` rules we just extend the configuration preset with `/rules/eslint/ecma-script-6/off.js`. | ||
|
||
### Full configurations | ||
|
||
This package includes the following complete and ready to use configurations: | ||
|
||
- `casumo` - ES5 config | ||
- `casumo/configurations/es5` - ES5 config | ||
- `casumo/configurations/es5-browser` - ES5 + browser | ||
- `casumo/configurations/es5-node` - ES5 + node | ||
- `casumo/configurations/es5-test` - ES5 + test | ||
- `casumo/configurations/es6` - ES6 config | ||
- `casumo/configurations/es6-browser` - ES6 + browser | ||
- `casumo/configurations/es6-node` - ES6 + node | ||
- `casumo/configurations/es6-test` - ES6 + test | ||
- `casumo/configurations/off` - All rules disabled | ||
|
||
## NPM scripts | ||
|
||
- `commit` - use this if you do not have [`commitizen`](https://github.com/commitizen/cz-cli) installed globally | ||
- `lint` - lints the current project | ||
- `find-new-eslint-rules` - checks for new (missing) rules | ||
- `test` - runs a couple of tests | ||
|
||
## Contributing | ||
|
||
To contribute to the project, please follow these steps: | ||
|
||
0. File an issue with the idea you wish to put forward | ||
0. Fork the repo | ||
0. Make a branch for your change | ||
0. Run `npm` or `yarn install` | ||
0. Make your changes | ||
0. Run `npm` or `yarn test` | ||
0. Run `git add -A` to add your changes | ||
0. Run `npm` or `yarn run commit` (do not use git commit - unless you have [`commitizen`](https://github.com/commitizen/cz-cli) installed globally) | ||
0. Push your changes | ||
0. Create the Pull Request | ||
0. Get merged and 🎉! | ||
|
||
## Thanks to | ||
- [eslint-config-walmart](https://github.com/walmartlabs/eslint-config-walmart) - for inspiration |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: './es5.js', | ||
env: { | ||
browser: true | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es5.js', | ||
'../rules/eslint/node-js-and-common-js/on.js' | ||
], | ||
env: { | ||
node: true | ||
}, | ||
rules: { | ||
strict: [2, 'global'] | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es5.js', | ||
'../rules/mocha/on.js' | ||
], | ||
env: { | ||
mocha: true | ||
}, | ||
rules: { | ||
'max-nested-callbacks': 0, | ||
'no-magic-numbers': 0 | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
extends: [ | ||
'../rules/eslint/best-practices/on.js', | ||
'../rules/eslint/possible-errors/on.js', | ||
'../rules/eslint/ecma-script-6/off.js', | ||
'../rules/eslint/node-js-and-common-js/off.js', | ||
'../rules/eslint/strict-mode/on.js', | ||
'../rules/eslint/stylistic-issues/on.js', | ||
'../rules/eslint/variables/on.js', | ||
// The following line is needed since `eslint-find-rules -u` does not skip deprecated rules. | ||
// This can be removed once https://github.com/sarbbottam/eslint-find-rules/issues/172 is resolved. | ||
'../rules/eslint/deprecated/off.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we require in turned off rules here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To get a green light from Currently it is throwing an error if the deprecated rules are not included. Waiting on sarbbottam/eslint-find-rules#172 to be resolved and then we can safely remove them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, ok, I see now. Can we add a comment or a todo to these, so they are describing why they are there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree :) |
||
], | ||
parserOptions: { | ||
ecmaVersion: 5, | ||
sourceType: 'script', | ||
ecmaFeatures: {} | ||
}, | ||
env: { | ||
amd: true | ||
}, | ||
globals: { | ||
module: false, | ||
process: false | ||
}, | ||
rules: {} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: './es6.js', | ||
env: { | ||
browser: true | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es6-test.js' | ||
], | ||
env: { | ||
mocha: true, | ||
phantomjs: true | ||
}, | ||
globals: { | ||
expect: true, | ||
sandbox: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we add
as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aaa, cool I missed that :P 👍 |
||
}, | ||
rules: { | ||
'max-nested-callbacks': 0, | ||
'no-unused-expressions': 0, | ||
'no-magic-numbers': 0 | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es6.js', | ||
'../rules/eslint/node-js-and-common-js/on.js' | ||
], | ||
env: { | ||
node: true | ||
}, | ||
parserOptions: { | ||
sourceType: 'script', | ||
ecmaFeatures: { | ||
impliedStrict: false | ||
} | ||
}, | ||
globals: {}, | ||
rules: { | ||
'constructor-super': 0, | ||
'no-class-assign': 0, | ||
'no-dupe-class-members': 0, | ||
'no-this-before-super': 0, | ||
'prefer-reflect': 0, | ||
strict: [2, 'global'] | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es6.js' | ||
], | ||
env: { | ||
mocha: true, | ||
phantomjs: true | ||
}, | ||
rules: { | ||
'max-nested-callbacks': 0, | ||
'no-magic-numbers': 0 | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
extends: [ | ||
'./es5.js', | ||
'../rules/eslint/ecma-script-6/on.js' | ||
], | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
impliedStrict: true | ||
} | ||
}, | ||
env: { | ||
es6: true | ||
}, | ||
globals: {}, | ||
rules: {} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need a composition file for the turned off rules? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be useful if someone wants to have only small number of rules turned on. Composing a config file with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I think it is descriptive enough if you only import / define the rules that you would like to enable. As no eslint rules are enabled by default, when would someone need to import this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If you do not import all the off rules then |
||
extends: [ | ||
'../rules/eslint/best-practices/off.js', | ||
'../rules/eslint/possible-errors/off.js', | ||
'../rules/eslint/ecma-script-6/off.js', | ||
'../rules/eslint/node-js-and-common-js/off.js', | ||
'../rules/eslint/strict-mode/off.js', | ||
'../rules/eslint/stylistic-issues/off.js', | ||
'../rules/eslint/variables/off.js', | ||
// The following line is needed since `eslint-find-rules -u` does not skip deprecated rules. | ||
// This can be removed once https://github.com/sarbbottam/eslint-find-rules/issues/172 is resolved. | ||
'../rules/eslint/deprecated/off.js' | ||
], | ||
parserOptions: { | ||
ecmaVersion: 5, | ||
sourceType: 'script', | ||
ecmaFeatures: {} | ||
}, | ||
env: {}, | ||
globals: {}, | ||
rules: {} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any benefit of requiring in the turned off rules explicitly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because the idea is to always ship a full set of rules including on and off.
Like this we are explicitly ignoring
ecma-script-6
andnode-js-and-common-js
rules.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍