eslint-config-prettier
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -5,3 +5,3 @@ "use strict"; | ||
curly(options) { | ||
if (options.length < 1) { | ||
if (options.length === 0) { | ||
return true; | ||
@@ -15,3 +15,3 @@ } | ||
"lines-around-comment"(options) { | ||
if (options.length < 1) { | ||
if (options.length === 0) { | ||
return false; | ||
@@ -33,3 +33,3 @@ } | ||
"no-confusing-arrow"(options) { | ||
if (options.length < 1) { | ||
if (options.length === 0) { | ||
return true; | ||
@@ -40,12 +40,3 @@ } | ||
return !(firstOption && firstOption.allowParens); | ||
}, | ||
quotes(options) { | ||
if (options.length < 1) { | ||
return false; | ||
} | ||
const firstOption = options[0]; | ||
return firstOption === "backtick"; | ||
} | ||
}; |
@@ -0,1 +1,9 @@ | ||
### Version 3.1.0 (2018-09-22) | ||
- Added: Support for [eslint-plugin-unicorn]. Thanks to John Mars (@j0hnm4r5)! | ||
- Changed: The [quotes] rule is now allowed to be used to forbid unnecessary | ||
backticks. This means that the CLI helper tool no longer can automatically | ||
validate it, so you’ll need to refer the [quotes special rule | ||
documentation][quotes-special]. Thanks to Nick Petruzzelli (@npetruzzelli)! | ||
### Version 3.0.1 (2018-08-13) | ||
@@ -162,2 +170,3 @@ | ||
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard | ||
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn | ||
[flowtype/boolean-style]: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-boolean-style | ||
@@ -179,2 +188,4 @@ [function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline | ||
[prettier]: https://github.com/prettier | ||
[quotes]: https://eslint.org/docs/rules/quotes | ||
[quotes-special]: https://github.com/prettier/eslint-config-prettier/blob/8d264cd0a7f06c12e2e05415e0282a4f8f21ebc9/README.md#quotes | ||
[react/jsx-child-element-spacing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md | ||
@@ -181,0 +192,0 @@ [react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md |
{ | ||
"name": "eslint-config-prettier", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"license": "MIT", | ||
@@ -13,3 +13,4 @@ "author": "Simon Lydell", | ||
"react.js", | ||
"standard.js" | ||
"standard.js", | ||
"unicorn.js" | ||
], | ||
@@ -30,3 +31,4 @@ "bin": { | ||
"test:cli-sanity": "eslint --print-config . | node ./bin/cli.js", | ||
"test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity" | ||
"test:cli-sanity-warning": "eslint --print-config ./bin/cli.js | node ./bin/cli.js", | ||
"test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity && npm run test:cli-sanity-warning" | ||
}, | ||
@@ -37,13 +39,14 @@ "dependencies": { | ||
"devDependencies": { | ||
"babel-eslint": "^8.2.6", | ||
"cross-spawn": "^6.0.5", | ||
"eslint": "^5.3.0", | ||
"eslint-config-google": "^0.9.1", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"eslint-plugin-prettier": "^2.6.2", | ||
"eslint-plugin-react": "^7.10.0", | ||
"eslint-plugin-standard": "^3.1.0", | ||
"jest": "23.5.0", | ||
"prettier": "^1.14.2", | ||
"rimraf": "^2.6.2" | ||
"babel-eslint": "9.0.0", | ||
"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", | ||
"eslint-plugin-react": "7.11.1", | ||
"eslint-plugin-standard": "4.0.0", | ||
"eslint-plugin-unicorn": "6.0.1", | ||
"jest": "23.6.0", | ||
"prettier": "1.14.3", | ||
"rimraf": "2.6.2" | ||
}, | ||
@@ -50,0 +53,0 @@ "peerDependencies": { |
148
README.md
@@ -36,2 +36,3 @@ # eslint-config-prettier [![Build Status][travis-badge]][travis] | ||
- [eslint-plugin-standard] | ||
- [eslint-plugin-unicorn] | ||
@@ -46,3 +47,4 @@ Add extra exclusions for the plugins you use like so: | ||
"prettier/react", | ||
"prettier/standard" | ||
"prettier/standard", | ||
"prettier/unicorn" | ||
] | ||
@@ -92,6 +94,8 @@ } | ||
"plugin:react/recommended", | ||
"plugin:unicorn/recommended", | ||
"prettier", | ||
"prettier/flowtype", | ||
"prettier/react", | ||
"prettier/standard" | ||
"prettier/standard", | ||
"prettier/unicorn" | ||
], | ||
@@ -102,3 +106,4 @@ "plugins": [ | ||
"prettier", | ||
"standard" | ||
"standard", | ||
"unicorn" | ||
], | ||
@@ -162,3 +167,3 @@ "parserOptions": { | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -208,3 +213,3 @@ ```json | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -248,3 +253,3 @@ ```json | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -295,3 +300,3 @@ ```json | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -344,3 +349,3 @@ ```json | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -362,3 +367,3 @@ ```json | ||
Example configuration: | ||
Example ESLint configuration: | ||
@@ -373,2 +378,11 @@ ```json | ||
Example Prettier configuration (this is the default, so adding this is not | ||
required): | ||
```json | ||
{ | ||
"useTabs": false | ||
} | ||
``` | ||
### [no-unexpected-multiline] | ||
@@ -445,10 +459,18 @@ | ||
**This rule requires certain options.** | ||
**This rule requires certain options and certain Prettier options.** | ||
If you’d like to enforce the use of backticks rather than single or double | ||
quotes for strings, you can enable this rule. Otherwise, there’s no need to. | ||
Just remember to enable the `"backtick"` option! | ||
Usually, you don’t need this rule at all. But there are two cases where it could | ||
be useful: | ||
Example configuration: | ||
- To enforce the use of backticks rather than single or double quotes for | ||
strings. | ||
- To forbid backticks where regular strings could have been used. | ||
#### Enforce backticks | ||
If you’d like all strings to use backticks (never quotes), enable the | ||
`"backtick"` option. | ||
Example ESLint configuration: | ||
```json | ||
@@ -462,3 +484,77 @@ { | ||
#### Forbid unnecessary backticks | ||
In the following example, the first array item could have been written with | ||
quotes instead of backticks. | ||
```js | ||
const strings = [ | ||
`could have been a regular string`, | ||
` | ||
multiple | ||
lines | ||
`, | ||
`uses ${interpolation}`, | ||
String.raw`\tagged/`, | ||
]; | ||
``` | ||
If you’d like ESLint to enforce `` `could have been a regular string` `` being | ||
written as either `"could have been a regular string"` or `'could have been a | ||
regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option. | ||
- The first (string) option needs to be set to `"single"` or `"double"` and be | ||
kept in sync with Prettier’s [singleQuote] option. | ||
- The second (object) option needs the following properties: | ||
- `"avoidEscape": true` to follow Prettier’s [string formatting rules]. | ||
- `"allowTemplateLiterals": false` to disallow unnecessary backticks. | ||
##### Example _double_ quote configuration | ||
ESLint: | ||
```json | ||
{ | ||
"rules": { | ||
"quotes": [ | ||
"error", | ||
"double", | ||
{ "avoidEscape": true, "allowTemplateLiterals": false } | ||
] | ||
} | ||
} | ||
``` | ||
Prettier (this is the default, so adding this is not required): | ||
```json | ||
{ | ||
"singleQuote": false | ||
} | ||
``` | ||
##### Example _single_ quote configuration | ||
ESLint: | ||
```json | ||
{ | ||
"rules": { | ||
"quotes": [ | ||
"error", | ||
"single", | ||
{ "avoidEscape": true, "allowTemplateLiterals": false } | ||
] | ||
} | ||
} | ||
``` | ||
Prettier: | ||
```json | ||
{ | ||
"singleQuote": true | ||
} | ||
``` | ||
## Contributing | ||
@@ -468,9 +564,10 @@ | ||
- ESLint 5.3.0 | ||
- ESLint 5.6.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.2 | ||
- eslint-plugin-flowtype 2.50.0 | ||
- eslint-plugin-react 7.10.0 | ||
- eslint-plugin-standard 3.1.0 | ||
- prettier 1.14.3 | ||
- eslint-plugin-flowtype 2.50.1 | ||
- eslint-plugin-react 7.11.1 | ||
- eslint-plugin-standard 4.0.0 | ||
- eslint-plugin-unicorn 6.0.1 | ||
@@ -503,4 +600,4 @@ Have new rules been added since those versions? Have we missed any rules? Is | ||
// Prettier does not want spaces before the parentheses, but | ||
// eslint-config-foobar wants one. | ||
console.log (); | ||
// some-foobar-config wants one. | ||
console.log(); | ||
``` | ||
@@ -510,3 +607,4 @@ | ||
eslint-plugin-prettier at the same time – until `"prettier/foobar"` is added to | ||
the "extends" property of an ESLint config. | ||
the "extends" property of an ESLint config. The file should be formatted | ||
according to Prettier, and that formatting should disagree with the plugin. | ||
@@ -535,3 +633,4 @@ Finally, you need to mention the plugin in several places: | ||
- That the CLI works. | ||
- `"test:cli-sanity"` is a sanity check for the CLI. | ||
- `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the | ||
CLI. | ||
@@ -548,2 +647,3 @@ ## License | ||
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard | ||
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn | ||
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment | ||
@@ -558,3 +658,5 @@ [max-len]: https://eslint.org/docs/rules/max-len | ||
[quotes]: https://eslint.org/docs/rules/quotes | ||
[singleQuote]: https://prettier.io/docs/en/options.html#quotes | ||
[string formatting rules]: https://prettier.io/docs/en/rationale.html#strings | ||
[travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master | ||
[travis]: https://travis-ci.org/prettier/eslint-config-prettier |
36511
11
644
12
346