eslint-config-prettier
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -5,4 +5,5 @@ #!/usr/bin/env node | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const getStdin = require("get-stdin"); | ||
const pkg = require("../package.json"); | ||
const validators = require("./validators"); | ||
@@ -76,6 +77,10 @@ | ||
// This used to look at "files" in package.json, but that is not reliable due | ||
// to an npm bug. See: | ||
// https://github.com/prettier/eslint-config-prettier/issues/57 | ||
const allRules = Object.assign( | ||
Object.create(null), | ||
...pkg.files | ||
.filter(name => !name.includes("/")) | ||
...fs | ||
.readdirSync(path.join(__dirname, "..")) | ||
.filter(name => !name.startsWith(".") && name.endsWith(".js")) | ||
.map(ruleFileName => require(`../${ruleFileName}`).rules) | ||
@@ -82,0 +87,0 @@ ); |
@@ -0,1 +1,8 @@ | ||
### Version 3.2.0 (2018-11-10) | ||
- Added: Support for [eslint-plugin-vue]. | ||
- Fixed: The CLI helper tool should now work in Node.js 6 with npm 3 again. | ||
Thanks to Grant Snodgrass (@meeber)! | ||
- Improved: Updated documentation. | ||
### Version 3.1.0 (2018-09-22) | ||
@@ -171,2 +178,3 @@ | ||
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn | ||
[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue | ||
[flowtype/boolean-style]: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-boolean-style | ||
@@ -173,0 +181,0 @@ [function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline |
{ | ||
"name": "eslint-config-prettier", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"license": "MIT", | ||
@@ -14,3 +14,4 @@ "author": "Simon Lydell", | ||
"standard.js", | ||
"unicorn.js" | ||
"unicorn.js", | ||
"vue.js" | ||
], | ||
@@ -26,4 +27,5 @@ "bin": { | ||
"scripts": { | ||
"doctoc": "doctoc README.md && replace \"\\[(\\[[\\w-]+\\])\\]\" \"\\$1\" README.md", | ||
"test:lint": "eslint .", | ||
"test:lint-verify-fail": "eslint test-lint/ --config .eslintrc.base.js --format json", | ||
"test:lint-verify-fail": "eslint \"test-lint/*.{js,vue}\" --config .eslintrc.base.js --format json", | ||
"test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json", | ||
@@ -39,13 +41,16 @@ "test:jest": "jest", | ||
"devDependencies": { | ||
"babel-eslint": "9.0.0", | ||
"babel-eslint": "10.0.1", | ||
"cross-spawn": "6.0.5", | ||
"eslint": "5.6.0", | ||
"eslint-config-google": "0.10.0", | ||
"eslint-plugin-flowtype": "2.50.1", | ||
"eslint-plugin-prettier": "2.6.2", | ||
"doctoc": "1.3.1", | ||
"eslint": "5.9.0", | ||
"eslint-config-google": "0.11.0", | ||
"eslint-plugin-flowtype": "3.2.0", | ||
"eslint-plugin-prettier": "3.0.0", | ||
"eslint-plugin-react": "7.11.1", | ||
"eslint-plugin-standard": "4.0.0", | ||
"eslint-plugin-unicorn": "6.0.1", | ||
"eslint-plugin-vue": "5.0.0-beta.3", | ||
"jest": "23.6.0", | ||
"prettier": "1.14.3", | ||
"prettier": "1.15.2", | ||
"replace": "1.0.0", | ||
"rimraf": "2.6.2" | ||
@@ -52,0 +57,0 @@ }, |
112
README.md
@@ -8,2 +8,31 @@ # eslint-config-prettier [![Build Status][travis-badge]][travis] | ||
## Contents | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
- [Installation](#installation) | ||
- [CLI helper tool](#cli-helper-tool) | ||
- [Example configuration](#example-configuration) | ||
- [Special rules](#special-rules) | ||
- [curly](#curly) | ||
- [lines-around-comment](#lines-around-comment) | ||
- [max-len](#max-len) | ||
- [no-confusing-arrow](#no-confusing-arrow) | ||
- [no-mixed-operators](#no-mixed-operators) | ||
- [no-tabs](#no-tabs) | ||
- [no-unexpected-multiline](#no-unexpected-multiline) | ||
- [quotes](#quotes) | ||
- [Enforce backticks](#enforce-backticks) | ||
- [Forbid unnecessary backticks](#forbid-unnecessary-backticks) | ||
- [Example _double_ quote configuration](#example-_double_-quote-configuration) | ||
- [Example _single_ quote configuration](#example-_single_-quote-configuration) | ||
- [Other rules worth mentioning](#other-rules-worth-mentioning) | ||
- [no-sequences](#no-sequences) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
## Installation | ||
@@ -38,2 +67,3 @@ | ||
- [eslint-plugin-unicorn] | ||
- [eslint-plugin-vue] | ||
@@ -49,3 +79,4 @@ Add extra exclusions for the plugins you use like so: | ||
"prettier/standard", | ||
"prettier/unicorn" | ||
"prettier/unicorn", | ||
"prettier/vue" | ||
] | ||
@@ -96,2 +127,3 @@ } | ||
"plugin:unicorn/recommended", | ||
"plugin:vue/recommended", | ||
"prettier", | ||
@@ -108,3 +140,4 @@ "prettier/flowtype", | ||
"standard", | ||
"unicorn" | ||
"unicorn", | ||
"vue" | ||
], | ||
@@ -552,2 +585,62 @@ "parserOptions": { | ||
## Other rules worth mentioning | ||
These rules don’t conflict with Prettier, but have some gotchas when used with | ||
Prettier. | ||
### [no-sequences] | ||
This rule forbids using JavaScript’s confusing comma operator (sequence | ||
expressions). This piece of code is not doing what it looks like: | ||
```js | ||
matrix[4, 7]; | ||
``` | ||
Prettier adds parentheses to the above to make it clear that a sequence | ||
expression is used: | ||
```js | ||
matrix[(4, 7)]; | ||
``` | ||
However, the `no-sequences` rule allows comma operators if the expression | ||
sequence is explicitly wrapped in parentheses. Since Prettier automatically | ||
wraps them in parentheses, you might never see any warnings from ESLint about | ||
comma operators. | ||
Ending up with an accidental sequence expression can easily happen while | ||
refactoring. If you want ESLint to catch such mistakes, it is recommended to | ||
forbid sequence expressions entirely using [no-restricted-syntax] \([as | ||
mentioned in the `no-sequences` documentation][no-sequences-full]): | ||
```json | ||
{ | ||
"rules": { | ||
"no-restricted-syntax": ["error", "SequenceExpression"] | ||
} | ||
} | ||
``` | ||
If you still need to use the comma operator for some edge case, you can place an | ||
`// eslint-disable-next-line no-restricted-syntax` comment on the line above the | ||
expression. `no-sequences` can safely be disabled if you use the | ||
`no-restricted-syntax` approach. | ||
You can also supply a custom message if you want: | ||
```json | ||
{ | ||
"rules": { | ||
"no-restricted-syntax": [ | ||
"error", | ||
{ | ||
"selector": "SequenceExpression", | ||
"message": "The comma operator is confusing and a common mistake. Don’t use it!" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
## Contributing | ||
@@ -557,10 +650,11 @@ | ||
- ESLint 5.6.0 | ||
- ESLint 5.9.0 | ||
- eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x | ||
- eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x | ||
- prettier 1.14.3 | ||
- eslint-plugin-flowtype 2.50.1 | ||
- prettier 1.15.2 | ||
- eslint-plugin-flowtype 3.2.0 | ||
- eslint-plugin-react 7.11.1 | ||
- eslint-plugin-standard 4.0.0 | ||
- eslint-plugin-unicorn 6.0.1 | ||
- eslint-plugin-vue 5.0.0-beta.3 | ||
@@ -617,4 +711,4 @@ Have new rules been added since those versions? Have we missed any rules? Is | ||
eslint-config-prettier itself. | ||
- `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.js`. | ||
- `"test:lint-rules"` is run by a test in `test/rules.js`. | ||
- `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`. | ||
- `"test:lint-rules"` is run by a test in `test/rules.test.js`. | ||
- `"test:jest"` runs unit tests that check a number of things: | ||
@@ -639,2 +733,3 @@ - That eslint-plugin-foobar is mentioned in all the places shown above. | ||
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn | ||
[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue | ||
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment | ||
@@ -645,2 +740,5 @@ [max-len]: https://eslint.org/docs/rules/max-len | ||
[no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators | ||
[no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax | ||
[no-sequences-full]: https://eslint.org/docs/rules/no-sequences#when-not-to-use-it | ||
[no-sequences]: https://eslint.org/docs/rules/no-sequences | ||
[no-tabs]: https://eslint.org/docs/rules/no-tabs | ||
@@ -647,0 +745,0 @@ [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
40967
12
368
742
15
2