Skip to content

Commit b24252d

Browse files
committed
init
0 parents  commit b24252d

File tree

7 files changed

+290
-0
lines changed

7 files changed

+290
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Evan You
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# eslint-plugin-vue-libs
2+
3+
ESLint plugin for libs in the vuejs organization. Note this is an internal plugin/config for the development of Vue itself, not intended for Vue app development.
4+
5+
## Usage
6+
7+
1. `npm install eslint-plugin-vue-libs --save-dev`
8+
2. create a file named `.eslintrc` in your project:
9+
10+
```js
11+
{
12+
 plugins: ["vue-libs"],
13+
extends: ["plugin:vue-libs/recommended"],
14+
rules: {
15+
// override if necessary
16+
}
17+
}
18+
```
19+
20+
## License
21+
22+
[MIT](http://opensource.org/licenses/MIT)

config.js

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
module.exports = {
2+
parserOptions: {
3+
ecmaVersion: 6,
4+
ecmaFeatures: {
5+
experimentalObjectRestSpread: true,
6+
jsx: true
7+
},
8+
sourceType: 'module'
9+
},
10+
11+
env: {
12+
es6: true,
13+
node: true
14+
},
15+
16+
plugins: ['vue'],
17+
18+
globals: {
19+
document: false,
20+
navigator: false,
21+
window: false
22+
},
23+
24+
rules: {
25+
'accessor-pairs': 2,
26+
'arrow-spacing': [2, { 'before': true, 'after': true }],
27+
'block-spacing': [2, 'always'],
28+
'brace-style': [2, '1tbs', { 'allowSingleLine': true }],
29+
'camelcase': [2, { 'properties': 'never' }],
30+
'comma-dangle': [2, 'never'],
31+
'comma-spacing': [2, { 'before': false, 'after': true }],
32+
'comma-style': [2, 'last'],
33+
'constructor-super': 2,
34+
'curly': [2, 'multi-line'],
35+
'dot-location': [2, 'property'],
36+
'eol-last': 2,
37+
'eqeqeq': [2, 'allow-null'],
38+
'generator-star-spacing': [2, { 'before': true, 'after': true }],
39+
'handle-callback-err': [2, '^(err|error)$' ],
40+
'indent': [2, 2, { 'SwitchCase': 1 }],
41+
'jsx-quotes': [2, 'prefer-single'],
42+
'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],
43+
'keyword-spacing': [2, { 'before': true, 'after': true }],
44+
'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }],
45+
'new-parens': 2,
46+
'no-array-constructor': 2,
47+
'no-caller': 2,
48+
'no-class-assign': 2,
49+
'no-cond-assign': 2,
50+
'no-const-assign': 2,
51+
'no-control-regex': 2,
52+
'no-delete-var': 2,
53+
'no-dupe-args': 2,
54+
'no-dupe-class-members': 2,
55+
'no-dupe-keys': 2,
56+
'no-duplicate-case': 2,
57+
'no-empty-character-class': 2,
58+
'no-empty-pattern': 2,
59+
'no-eval': 2,
60+
'no-ex-assign': 2,
61+
'no-extend-native': 2,
62+
'no-extra-bind': 2,
63+
'no-extra-boolean-cast': 2,
64+
'no-extra-parens': [2, 'functions'],
65+
'no-fallthrough': 2,
66+
'no-floating-decimal': 2,
67+
'no-func-assign': 2,
68+
'no-implied-eval': 2,
69+
'no-inner-declarations': [2, 'functions'],
70+
'no-invalid-regexp': 2,
71+
'no-irregular-whitespace': 2,
72+
'no-iterator': 2,
73+
'no-label-var': 2,
74+
'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }],
75+
'no-lone-blocks': 2,
76+
'no-mixed-spaces-and-tabs': 2,
77+
'no-multi-spaces': 2,
78+
'no-multi-str': 2,
79+
'no-multiple-empty-lines': [2, { 'max': 1 }],
80+
'no-native-reassign': 2,
81+
'no-negated-in-lhs': 2,
82+
'no-new-object': 2,
83+
'no-new-require': 2,
84+
'no-new-symbol': 2,
85+
'no-new-wrappers': 2,
86+
'no-obj-calls': 2,
87+
'no-octal': 2,
88+
'no-octal-escape': 2,
89+
'no-path-concat': 2,
90+
'no-proto': 2,
91+
'no-redeclare': 2,
92+
'no-regex-spaces': 2,
93+
'no-return-assign': [2, 'except-parens'],
94+
'no-self-assign': 2,
95+
'no-self-compare': 2,
96+
'no-sequences': 2,
97+
'no-shadow-restricted-names': 2,
98+
'no-spaced-func': 2,
99+
'no-sparse-arrays': 2,
100+
'no-this-before-super': 2,
101+
'no-throw-literal': 2,
102+
'no-trailing-spaces': 2,
103+
'no-undef': 2,
104+
'no-undef-init': 2,
105+
'no-unexpected-multiline': 2,
106+
'no-unmodified-loop-condition': 2,
107+
'no-unneeded-ternary': [2, { 'defaultAssignment': false }],
108+
'no-unreachable': 2,
109+
'no-unsafe-finally': 2,
110+
'no-unused-vars': [2, { 'vars': 'all', 'args': 'none' }],
111+
'no-useless-call': 2,
112+
'no-useless-computed-key': 2,
113+
'no-useless-constructor': 2,
114+
'no-useless-escape': 0,
115+
'no-whitespace-before-property': 2,
116+
'no-with': 2,
117+
'one-var': [2, { 'initialized': 'never' }],
118+
'operator-linebreak': [2, 'after', { 'overrides': { '?': 'before', ':': 'before' } }],
119+
'padded-blocks': [2, 'never'],
120+
'quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
121+
'semi': [2, 'never'],
122+
'semi-spacing': [2, { 'before': false, 'after': true }],
123+
'space-before-blocks': [2, 'always'],
124+
'space-before-function-paren': [2, 'always'],
125+
'space-in-parens': [2, 'never'],
126+
'space-infix-ops': 2,
127+
'space-unary-ops': [2, { 'words': true, 'nonwords': false }],
128+
'spaced-comment': [2, 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }],
129+
'template-curly-spacing': [2, 'never'],
130+
'use-isnan': 2,
131+
'valid-typeof': 2,
132+
'wrap-iife': [2, 'any'],
133+
'yield-star-spacing': [2, 'both'],
134+
'yoda': [2, 'never'],
135+
'prefer-const': 2,
136+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
137+
'object-curly-spacing': [2, 'always', { objectsInObjects: false }],
138+
'array-bracket-spacing': [2, 'never'],
139+
'vue/jsx-uses-vars': 2
140+
}
141+
}

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
module.exports = {
4+
configs: {
5+
recommended: require('./config')
6+
},
7+
rules: {
8+
'jsx-uses-vars': require('./rules/jsx-uses-vars')
9+
}
10+
}

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "eslint-plugin-vue-libs",
3+
"version": "1.0.0",
4+
"description": "eslint plugin for vue.js projects",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/vuejs/eslint-plugin-vue-libs.git"
9+
},
10+
"author": "Evan You",
11+
"license": "MIT",
12+
"bugs": {
13+
"url": "https://github.com/vuejs/eslint-plugin-vue-libs/issues"
14+
},
15+
"homepage": "https://github.com/vuejs/eslint-plugin-vue-libs#readme",
16+
"peerDependencies": {
17+
"eslint": "^2.0.0 || ^3.0.0"
18+
}
19+
}

rules/jsx-uses-vars.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// the following rule is based on yannickcr/eslint-plugin-react
2+
3+
/**
4+
The MIT License (MIT)
5+
6+
Copyright (c) 2014 Yannick Croissant
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.
25+
*/
26+
27+
/**
28+
* @fileoverview Prevent variables used in JSX to be marked as unused
29+
* @author Yannick Croissant
30+
*/
31+
'use strict';
32+
33+
// ------------------------------------------------------------------------------
34+
// Rule Definition
35+
// ------------------------------------------------------------------------------
36+
37+
module.exports = {
38+
meta: {
39+
docs: {
40+
description: 'Prevent variables used in JSX to be marked as unused',
41+
category: 'Best Practices',
42+
recommended: true
43+
},
44+
schema: []
45+
},
46+
47+
create: function(context) {
48+
49+
return {
50+
JSXOpeningElement: function(node) {
51+
var name;
52+
if (node.name.namespace && node.name.namespace.name) {
53+
// <Foo:Bar>
54+
name = node.name.namespace.name;
55+
} else if (node.name.name) {
56+
// <Foo>
57+
name = node.name.name;
58+
} else if (node.name.object) {
59+
// <Foo...Bar>
60+
var parent = node.name.object;
61+
while (parent.object) {
62+
parent = parent.object;
63+
}
64+
name = parent.name;
65+
} else {
66+
return;
67+
}
68+
69+
context.markVariableAsUsed(name);
70+
}
71+
72+
};
73+
74+
}
75+
};

0 commit comments

Comments
 (0)