diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..fdcea4006 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,102 @@ +workflows: + version: 2 + node-multi-build: + jobs: + - node-v6: + filters: + branches: + ignore: gh-pages + - node-v8: + filters: + branches: + ignore: gh-pages + - node-v10: + filters: + branches: + ignore: gh-pages + - node-v10-minimal: + filters: + branches: + ignore: gh-pages + - deploy_docs: + requires: + - node-v10 + filters: + branches: + only: master + +version: 2 +jobs: + node-base: &node-base + docker: + - image: node + steps: + - run: + name: Versions + command: npm version + - checkout + - restore_cache: + keys: + - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} + - run: + name: Install dependencies + command: npm install + - save_cache: + key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} + paths: + - node_modules + - run: + name: Test + command: npm test + + node-v6: + <<: *node-base + docker: + - image: node:6 + node-v8: + <<: *node-base + docker: + - image: node:8 + node-v10: + <<: *node-base + docker: + - image: node:10 + node-v10-minimal: + steps: + - run: + name: Versions + command: npm version + - checkout + - restore_cache: + keys: + - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} + - run: + name: Install dependencies + command: npm install + - run: + name: Install eslint 5 + command: npm install eslint@5.0.0 --no-save + - run: + name: Test + command: npm test + - save_cache: + key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} + paths: + - node_modules + docker: + - image: node:10 + + deploy_docs: + docker: + - image: node:10 + steps: + - checkout + - restore_cache: + keys: + - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} + - run: + name: Install dependencies + command: npm install + - run: + name: Deploy to Github Pages + command: npm run docs:deploy diff --git a/.eslintignore b/.eslintignore index 9efb24842..20f3203c8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,6 @@ /node_modules /tests/fixtures /tests/integrations/*/node_modules + +!.vuepress +/docs/.vuepress/dist diff --git a/.eslintrc.js b/.eslintrc.js index 4b8396bec..b8f76a4f4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,9 +19,10 @@ module.exports = { 'eslint-plugin' ], rules: { - 'eslint-plugin/report-message-format': ['error', '^[A-Z`\'].*\\.$'], + 'eslint-plugin/report-message-format': ['error', '^[A-Z`\'{].*\\.$'], 'eslint-plugin/prefer-placeholders': 'error', - 'eslint-plugin/consistent-output': 'error' + 'eslint-plugin/consistent-output': 'error', + 'no-mixed-operators': 'error' }, overrides: [{ diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 9a3407f13..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,39 +0,0 @@ - - -**Tell us about your environment** - -* **ESLint Version:** -* **eslint-plugin-vue Version:** -* **Node Version:** - -**Please show your full configuration:** - - -``` - - - - -``` - -**What did you do? Please include the actual source code causing the issue.** - - -```vue - - - - - -``` - -**What did you expect to happen?** - -**What actually happened? Please include the actual, raw output from ESLint.** diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..1dd689274 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + + + +**Tell us about your environment** +* **ESLint version:** +* **eslint-plugin-vue version:** +* **Node version:** + +**Please show your full configuration:** + +```json + +``` + +**What did you do?** + +```vue + +``` + +**What did you expect to happen?** + + +**What actually happened?** + diff --git a/.github/ISSUE_TEMPLATE/rule-proposal.md b/.github/ISSUE_TEMPLATE/rule-proposal.md new file mode 100644 index 000000000..7130c789f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rule-proposal.md @@ -0,0 +1,29 @@ +--- +name: Rule Proposal +about: Suggest an idea for a new rule + +--- + + + +**Please describe what the rule should do:** + + +**What category should the rule belong to?** + +- [ ] Enforces code style +- [ ] Warns about a potential error +- [ ] Suggests an alternate way of doing something +- [ ] Other (please specify:) + +**Provide 2-3 code examples that this rule should warn about:** +```vue + +``` + +**Additional context** + diff --git a/.gitignore b/.gitignore index 1828a214c..688618a31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +*.iml /.nyc_output /coverage /tests/integrations/*/node_modules @@ -6,3 +7,4 @@ /test.* yarn.lock yarn-error.log +docs/.vuepress/dist diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..324a79864 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Start testing", + "program": "${workspaceFolder}/node_modules/.bin/mocha", + "args": [ + "${file}", + "--watch" + ], + "console": "integratedTerminal" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 6287f25a9..7bd96f8d9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,10 @@ "editor.tabSize": 2, "eslint.options": { "rulePaths": ["eslint-internal-rules"] - } + }, + "eslint.validate": [ + "javascript", + "javascriptreact", + { "language": "vue", "autoFix": true } + ] } diff --git a/README.md b/README.md index b070b4098..a983f6e42 100644 --- a/README.md +++ b/README.md @@ -2,291 +2,52 @@ [![NPM version](https://img.shields.io/npm/v/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) -[![CircleCI](https://circleci.com/gh/vuejs/eslint-plugin-vue.svg?style=svg)](https://circleci.com/gh/vuejs/eslint-plugin-vue) +[![CircleCI](https://img.shields.io/circleci/project/github/vuejs/eslint-plugin-vue/master.svg?style=flat)](https://circleci.com/gh/vuejs/eslint-plugin-vue) +[![License](https://img.shields.io/github/license/vuejs/eslint-plugin-vue.svg?style=flat)](https://github.com/vuejs/eslint-plugin-vue/blob/master/LICENSE.md) > Official ESLint plugin for Vue.js -## :art: Playground on the Web +## :book: Documentation -You can try this plugin on the Web. +See https://vuejs.github.io/eslint-plugin-vue/ -- https://mysticatea.github.io/vue-eslint-demo/ +## :anchor: Versioning Policy -## :grey_exclamation: Requirements +This plugin is following [Semantic Versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). -- [ESLint](http://eslint.org/) `>=3.18.0`. - - `>=4.7.0` to use `eslint --fix`. - - `>=4.14.0` to use with `babel-eslint`. -- Node.js `>=4.0.0` - -## :cd: Installation - -```bash -npm install --save-dev eslint eslint-plugin-vue -``` - -## :rocket: Usage - -Create `.eslintrc.*` file to configure rules. See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring). - -Example **.eslintrc.js**: - -```js -module.exports = { - extends: [ - // add more generic rulesets here, such as: - // 'eslint:recommended', - 'plugin:vue/essential' - ], - rules: { - // override/add rules settings here, such as: - // 'vue/no-unused-vars': 'error' - } -} -``` - -### Single File Components - -ESLint only targets `.js` files by default. You must include the `.vue` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern. - -Examples: - -```bash -eslint --ext .js,.vue src -eslint src/**/*.{js,vue} -``` - -### Attention - -All component-related rules are being applied to code that passes any of the following checks: - -* `Vue.component()` expression -* `Vue.extend()` expression -* `Vue.mixin()` expression -* `export default {}` in `.vue` or `.jsx` file - -If you however want to take advantage of our rules in any of your custom objects that are Vue components, you might need to use special comment `// @vue/component` that marks object in the next line as a Vue component in any file, e.g.: - -```js -// @vue/component -const CustomComponent = { - name: 'custom-component', - template: '
' -} -``` -```js -Vue.component('AsyncComponent', (resolve, reject) => { - setTimeout(() => { - // @vue/component - resolve({ - name: 'async-component', - template: '
' - }) - }, 500) -}) -``` - -### `eslint-disable` functionality in `