eslint-config-prettier
Advanced tools
Comparing version 3.2.0 to 3.3.0
"use strict"; | ||
// These validator functions answer the question “Is the config valid?” – return | ||
// `false` if the options DO conflict with Prettier, and `true` if they don’t. | ||
module.exports = { | ||
@@ -37,3 +40,16 @@ curly(options) { | ||
return !(firstOption && firstOption.allowParens); | ||
}, | ||
"vue/html-self-closing"(options) { | ||
if (options.length === 0) { | ||
return false; | ||
} | ||
const firstOption = options[0]; | ||
return Boolean( | ||
firstOption && (firstOption.html && firstOption.html.void === "any") | ||
// Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322 | ||
// && firstOption.svg === "any" | ||
); | ||
} | ||
}; |
@@ -0,1 +1,6 @@ | ||
### Version 3.3.0 (2018-11-11) | ||
- Added: The [vue/html-self-closing] rule (as a [special | ||
rule][vue/html-self-closing-special]). Thanks to Yamagishi Kazutoshi (@ykzts)! | ||
### Version 3.2.0 (2018-11-10) | ||
@@ -204,1 +209,3 @@ | ||
[template-tag-spacing]: https://eslint.org/docs/rules/template-tag-spacing | ||
[vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md | ||
[vue/html-self-closing-special]: https://github.com/prettier/eslint-config-prettier/blob/d5e7af986221df5faedc12893d8dc3150a808693/README.md#vuehtml-self-closing |
{ | ||
"name": "eslint-config-prettier", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "author": "Simon Lydell", | ||
"scripts": { | ||
"doctoc": "doctoc README.md && replace \"\\[(\\[[\\w-]+\\])\\]\" \"\\$1\" README.md", | ||
"doctoc": "doctoc README.md && replace \"\\[(\\[[\\w/-]+\\])\\]\" \"\\$1\" README.md", | ||
"test:lint": "eslint .", | ||
@@ -29,0 +29,0 @@ "test:lint-verify-fail": "eslint \"test-lint/*.{js,vue}\" --config .eslintrc.base.js --format json", |
@@ -30,2 +30,3 @@ # eslint-config-prettier [![Build Status][travis-badge]][travis] | ||
- [Example _single_ quote configuration](#example-_single_-quote-configuration) | ||
- [vue/html-self-closing](#vuehtml-self-closing) | ||
- [Other rules worth mentioning](#other-rules-worth-mentioning) | ||
@@ -130,3 +131,4 @@ - [no-sequences](#no-sequences) | ||
"prettier/standard", | ||
"prettier/unicorn" | ||
"prettier/unicorn", | ||
"prettier/vue" | ||
], | ||
@@ -412,2 +414,15 @@ "plugins": [ | ||
**Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of | ||
your Prettier configuration: | ||
```json | ||
{ | ||
"rules": { | ||
"no-tabs": ["error", {"allowIndentationTabs": true}] | ||
} | ||
} | ||
``` | ||
A future version of eslint-config-prettier might check for that automatically. | ||
### [no-unexpected-multiline] | ||
@@ -583,2 +598,40 @@ | ||
### [vue/html-self-closing] | ||
This rule enforces whether elements should be self-closing or not. | ||
Prettier generally preserves the way you wrote your elements: | ||
```vue | ||
<div /> | ||
<div></div> | ||
<MyComponent /> | ||
<MyComponent></MyComponent> | ||
<svg><path d="" /></svg> | ||
<svg><path d=""></path></svg> | ||
``` | ||
But for known _void_ HTML elements, Prettier always uses the self-closing style. | ||
For example, `<img>` is turned into `<img />`. | ||
If you like this rule, it can be used just fine with Prettier as long as you | ||
set `html.void` to `"any"`. | ||
Example ESLint configuration: | ||
```json | ||
{ | ||
"rules": { | ||
"vue/html-self-closing": [ | ||
"error", | ||
{ | ||
"html": { | ||
"void": "any" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
## Other rules worth mentioning | ||
@@ -722,2 +775,3 @@ | ||
[ESlint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released | ||
[Prettier]: https://github.com/prettier/prettier | ||
@@ -747,1 +801,2 @@ [curly]: https://eslint.org/docs/rules/curly | ||
[travis]: https://travis-ci.org/prettier/eslint-config-prettier | ||
[vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md |
@@ -5,2 +5,4 @@ "use strict"; | ||
rules: { | ||
"vue/html-self-closing": 0, | ||
"vue/html-closing-bracket-newline": "off", | ||
@@ -7,0 +9,0 @@ "vue/html-closing-bracket-spacing": "off", |
43232
382
797