├── test
├── no.script.vue
├── fixture.vue
└── test.js
├── .eslintrc
├── lib
├── index.js
└── processors
│ └── vueProcessor.js
├── .gitattributes
├── README.md
├── package.json
├── license
└── .gitignore
/test/no.script.vue:
--------------------------------------------------------------------------------
1 |
2 | {{msg}}
3 |
4 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends":"standard",
3 | "env":{
4 | "node":true,
5 | "es6":true,
6 | "mocha":true
7 | },
8 | "rules":{
9 | "semi":[2, "never"]
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/fixture.vue:
--------------------------------------------------------------------------------
1 |
2 | {{msg}}
3 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview eslint plugin for vue component
3 | * @author Twiknight
4 | * @copyright 2016 Twiknight. All rights reserved.
5 | * See LICENSE file in root directory for full license.
6 | */
7 | 'use strict'
8 |
9 | const processor = require('./processors/vueProcessor')
10 |
11 | module.exports.processors = {
12 | '.vue': processor
13 | }
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/lib/processors/vueProcessor.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const parse5 = require('parse5')
4 |
5 | let offset = 0
6 |
7 | module.exports = {
8 | preprocess: function (text, filename) {
9 | const fragments = parse5.parseFragment(text, {locationInfo: true}).childNodes
10 | for (let i = 0; i < fragments.length; i++) {
11 | let frag = fragments[i]
12 | if (frag.tagName === 'script') {
13 | offset = frag.__location.line - 1
14 | return [frag.childNodes[0].value]
15 | }
16 | }
17 | return ['']
18 | },
19 | postprocess: function (messages, filename) {
20 | messages[0].forEach(function (m) {
21 | m.line += offset
22 | })
23 | return messages[0]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # DEPRECATED!
3 |
4 | This project is deprecated and no longer maintained!
5 |
6 | Please use the official linter: [https://github.com/vuejs/eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
7 |
8 |
9 | # eslint-plugin-vue
10 |
11 | eslint plugin for vue component files (I mean, `.vue` files).
12 |
13 | ## Installation
14 |
15 | You'll first need to install [ESLint](http://eslint.org):
16 |
17 | ```
18 | $ npm i eslint --save-dev
19 | ```
20 |
21 | Next, install `eslint-plugin-vue`:
22 |
23 | ```
24 | $ npm install eslint-plugin-vue --save-dev
25 | ```
26 |
27 | **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-vue` globally.
28 |
29 | ## Usage
30 |
31 | Add `vue` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
32 |
33 | ```json
34 | {
35 | "plugins": [
36 | "vue"
37 | ]
38 | }
39 | ```
40 |
41 | ## License
42 |
43 | MIT
44 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-plugin-vue",
3 | "version": "0.1.1",
4 | "description": "eslint plugin for vue components (.vue files)",
5 | "keywords": [
6 | "eslint",
7 | "eslintplugin",
8 | "eslint-plugin",
9 | "vue",
10 | "linter"
11 | ],
12 | "author": "Twiknight",
13 | "main": "lib/index.js",
14 | "scripts": {
15 | "test": "mocha"
16 | },
17 | "dependencies": {
18 | "parse5": "^2.1.5"
19 | },
20 | "devDependencies": {
21 | "chai": "^3.5.0",
22 | "eslint": "^2.4.0",
23 | "eslint-config-standard": "^5.1.0",
24 | "eslint-plugin-promise": "^1.1.0",
25 | "eslint-plugin-standard": "^1.3.2",
26 | "mocha": "^2.4.5"
27 | },
28 | "peerDependencies": {
29 | "eslint": ">=2.0.0"
30 | },
31 | "engines": {
32 | "node": ">=4.0.0"
33 | },
34 | "license": "MIT",
35 | "repository": {
36 | "type": "git",
37 | "url": "https://github.com/Twiknight/eslint-plugin-vue.git"
38 | },
39 | "bugs": {
40 | "url": "https://github.com/Twiknight/eslint-plugin-vue/issues"
41 | },
42 | "homepage": "https://github.com/Twiknight/eslint-plugin-vue/"
43 | }
44 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 TwiKnight
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const expect = require('chai').expect
4 | const CLIEngine = require('eslint').CLIEngine
5 | const plugin = require('../lib/index')
6 | const Path = require('path')
7 |
8 | describe('should work with vue', function (done) {
9 | const cli = new CLIEngine({
10 | envs: ['es6'],
11 | useEslintrc: false,
12 | rules: {semi: [2, 'never']},
13 | parserOptions: {
14 | ecmaVersion: 6,
15 | sourceType: 'module'
16 | }
17 | })
18 |
19 | it('should work with vue', function (done) {
20 | cli.addPlugin('eslint-plugin-vue', plugin)
21 | const filename = Path.join(__dirname, 'fixture.vue')
22 |
23 | const report = cli.executeOnFiles([filename])
24 | const errors = report.results[0].messages
25 |
26 | expect(errors).to.have.lengthOf(1)
27 | expect(errors[0]).to.have.property('line', 10)
28 | expect(errors[0]).to.have.property('ruleId', 'semi')
29 | done()
30 | })
31 |
32 | // issue: https://github.com/Twiknight/eslint-plugin-vue/issues/1
33 | it('should work with vue files without script tag', function () {
34 | cli.addPlugin('eslint-plugin-vue', plugin)
35 | const filename = Path.join(__dirname, 'no.script.vue')
36 |
37 | const report = cli.executeOnFiles([filename])
38 | const errors = report.results[0].messages
39 |
40 | expect(errors).to.have.lengthOf(0)
41 | })
42 | })
43 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # node-waf configuration
21 | .lock-wscript
22 |
23 | # Compiled binary addons (http://nodejs.org/api/addons.html)
24 | build/Release
25 |
26 | # Dependency directory
27 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
28 | node_modules
29 |
30 | # =========================
31 | # Operating System Files
32 | # =========================
33 |
34 | # OSX
35 | # =========================
36 |
37 | .DS_Store
38 | .AppleDouble
39 | .LSOverride
40 |
41 | # Thumbnails
42 | ._*
43 |
44 | # Files that might appear in the root of a volume
45 | .DocumentRevisions-V100
46 | .fseventsd
47 | .Spotlight-V100
48 | .TemporaryItems
49 | .Trashes
50 | .VolumeIcon.icns
51 |
52 | # Directories potentially created on remote AFP share
53 | .AppleDB
54 | .AppleDesktop
55 | Network Trash Folder
56 | Temporary Items
57 | .apdisk
58 |
59 | # Windows
60 | # =========================
61 |
62 | # Windows image file caches
63 | Thumbs.db
64 | ehthumbs.db
65 |
66 | # Folder config file
67 | Desktop.ini
68 |
69 | # Recycle Bin used on file shares
70 | $RECYCLE.BIN/
71 |
72 | # Windows Installer files
73 | *.cab
74 | *.msi
75 | *.msm
76 | *.msp
77 |
78 | # Windows shortcuts
79 | *.lnk
80 |
--------------------------------------------------------------------------------