Skip to content

Commit

Permalink
Add support for eslint-plugin-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Nov 10, 2018
1 parent e47404c commit 351d791
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 11 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ module.exports = {
"google",
"plugin:flowtype/recommended",
"plugin:react/all",
"plugin:unicorn/recommended"
"plugin:unicorn/recommended",
"plugin:vue/recommended"
],
plugins: [
"prettier",
...pkg.files
.filter(name => !name.includes("/") && name !== "index.js")
.map(ruleFileName => ruleFileName.replace(/\.js$/, ""))
],
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 2016,
parser: "babel-eslint",
ecmaVersion: 2018,
sourceType: "script",
ecmaFeatures: {
jsx: true
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ A few ESLint plugins are supported as well:
- [eslint-plugin-react]
- [eslint-plugin-standard]
- [eslint-plugin-unicorn]
- [eslint-plugin-vue]

Add extra exclusions for the plugins you use like so:

Expand All @@ -73,7 +74,8 @@ Add extra exclusions for the plugins you use like so:
"prettier/flowtype",
"prettier/react",
"prettier/standard",
"prettier/unicorn"
"prettier/unicorn",
"prettier/vue"
]
}
```
Expand Down Expand Up @@ -119,6 +121,7 @@ Exit codes:
"plugin:flowtype/recommended",
"plugin:react/recommended",
"plugin:unicorn/recommended",
"plugin:vue/recommended",
"prettier",
"prettier/flowtype",
"prettier/react",
Expand All @@ -130,7 +133,8 @@ Exit codes:
"react",
"prettier",
"standard",
"unicorn"
"unicorn",
"vue"
],
"parserOptions": {
"sourceType": "module",
Expand Down Expand Up @@ -645,6 +649,7 @@ eslint-config-prettier has been tested with:
- 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

Have new rules been added since those versions? Have we missed any rules? Is
there a plugin you would like to see exclusions for? Open an issue or a pull
Expand Down Expand Up @@ -696,8 +701,8 @@ several other npm scripts:
- `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when
the exclusions from eslint-config-prettier are used. It also lints the code of
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:
- That eslint-plugin-foobar is mentioned in all the places shown above.
- That no unknown rules are turned off. This helps catching typos, for
Expand All @@ -717,6 +722,7 @@ several other npm scripts:
[eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
[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
[max-len]: https://eslint.org/docs/rules/max-len
[multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"index.js",
"react.js",
"standard.js",
"unicorn.js"
"unicorn.js",
"vue.js"
],
"bin": {
"eslint-config-prettier-check": "bin/cli.js"
Expand All @@ -24,7 +25,7 @@
"scripts": {
"doctoc": "doctoc 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",
"test:jest": "jest",
"test:cli-sanity": "eslint --print-config . | node ./bin/cli.js",
Expand All @@ -45,6 +46,7 @@
"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.15.2",
"rimraf": "2.6.2"
Expand Down
7 changes: 7 additions & 0 deletions test-lint/vue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Prettier can put several attributes on one line, but "plugin:vue/recommended"
wants at most one per line.
-->
<template>
<div v-if="!isFirst" class="container">content</div>
</template>
2 changes: 1 addition & 1 deletion test/lint-verify-fail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("test-lint/ causes errors without eslint-config-prettier", () => {
});

output.forEach(data => {
const name = path.basename(data.filePath).replace(/\.js$/, "");
const name = path.basename(data.filePath).replace(/\.(?:js|vue)$/, "");
const ruleIds = data.messages.map(message => message.ruleId);

describe(name, () => {
Expand Down
3 changes: 2 additions & 1 deletion test/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ describe("all rule files are listed in package.json", () => {
describe("all rule files have tests in test-lint/", () => {
ruleFiles.forEach(ruleFileName => {
test(ruleFileName, () => {
expect(fs.existsSync(path.join("test-lint", ruleFileName))).toBe(true);
const testFileName = ruleFileName === "vue.js" ? "vue.vue" : ruleFileName;
expect(fs.existsSync(path.join("test-lint", testFileName))).toBe(true);
});
});
});
Expand Down
18 changes: 18 additions & 0 deletions vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

module.exports = {
rules: {
"vue/html-closing-bracket-newline": "off",
"vue/html-closing-bracket-spacing": "off",
"vue/html-end-tags": "off",
"vue/html-indent": "off",
"vue/html-quotes": "off",
"vue/max-attributes-per-line": "off",
"vue/multiline-html-element-content-newline": "off",
"vue/mustache-interpolation-spacing": "off",
"vue/no-multi-spaces": "off",
"vue/no-spaces-around-equal-signs-in-attribute": "off",
"vue/script-indent": "off",
"vue/singleline-html-element-content-newline": "off"
}
};

0 comments on commit 351d791

Please sign in to comment.