vue.eslintrc.js常用配置

vue.eslintrc.js

  1 module.exports = {
  2   root: true,
  3   env: {
  4     node: true
  5   },
  6   extends: [
  7     "plugin:vue/essential", "eslint:recommended"
  8   ],
  9   rules: {
 10     'accessor-pairs': 2,
 11     'arrow-spacing': [
 12       2, {
 13         'before': true,
 14         'after': true
 15       }
 16     ],
 17     'block-spacing': [
 18       2, 'always'
 19     ],
 20     'brace-style': [
 21       2,
 22       '1tbs', {
 23         'allowSingleLine': true
 24       }
 25     ],
 26     'camelcase': [
 27       0, {
 28         'properties': 'always'
 29       }
 30     ],
 31     'comma-dangle': [
 32       2, 'never'
 33     ],
 34     'comma-spacing': [
 35       2, {
 36         'before': false,
 37         'after': true
 38       }
 39     ],
 40     'comma-style': [
 41       2, 'last'
 42     ],
 43     'constructor-super': 2,
 44     'curly': [
 45       2, 'multi-line'
 46     ],
 47     'dot-location': [
 48       2, 'property'
 49     ],
 50     'eol-last': 2,
 51     'eqeqeq': [
 52       2, 'allow-null'
 53     ],
 54     'generator-star-spacing': [
 55       2, {
 56         'before': true,
 57         'after': true
 58       }
 59     ],
 60     'handle-callback-err': [
 61       2, '^(err|error)$'
 62     ],
 63     'indent': [
 64       2,
 65       2, {
 66         'SwitchCase': 1
 67       }
 68     ],
 69     'jsx-quotes': [
 70       2, 'prefer-single'
 71     ],
 72     'key-spacing': [
 73       2, {
 74         'beforeColon': false,
 75         'afterColon': true
 76       }
 77     ],
 78     'keyword-spacing': [
 79       2, {
 80         'before': true,
 81         'after': true
 82       }
 83     ],
 84     'new-cap': [
 85       2, {
 86         'newIsCap': true,
 87         'capIsNew': false
 88       }
 89     ],
 90     'new-parens': 2,
 91     'no-array-constructor': 2,
 92     'no-caller': 2,
 93     'no-console': 'off',
 94     'no-class-assign': 2,
 95     'no-cond-assign': 2,
 96     'no-const-assign': 2,
 97     'no-control-regex': 2,
 98     'no-delete-var': 2,
 99     'no-dupe-args': 2,
100     'no-dupe-class-members': 2,
101     'no-dupe-keys': 2,
102     'no-duplicate-case': 2,
103     'no-empty-character-class': 2,
104     'no-empty-pattern': 2,
105     'no-eval': 2,
106     'no-ex-assign': 2,
107     'no-extend-native': 2,
108     'no-extra-bind': 2,
109     'no-extra-boolean-cast': 2,
110     'no-extra-parens': [
111       2, 'functions'
112     ],
113     'no-fallthrough': 2,
114     'no-floating-decimal': 2,
115     'no-func-assign': 2,
116     'no-implied-eval': 2,
117     'no-inner-declarations': [
118       2, 'functions'
119     ],
120     'no-invalid-regexp': 2,
121     'no-irregular-whitespace': 2,
122     'no-iterator': 2,
123     'no-label-var': 2,
124     'no-labels': [
125       2, {
126         'allowLoop': false,
127         'allowSwitch': false
128       }
129     ],
130     'no-lone-blocks': 2,
131     'no-mixed-spaces-and-tabs': 2,
132     'no-multi-spaces': 2,
133     'no-multi-str': 2,
134     'no-multiple-empty-lines': [
135       2, {
136         'max': 1
137       }
138     ],
139     'no-native-reassign': 2,
140     'no-negated-in-lhs': 2,
141     'no-new-object': 2,
142     'no-new-require': 2,
143     'no-new-symbol': 2,
144     'no-new-wrappers': 2,
145     'no-obj-calls': 2,
146     'no-octal': 2,
147     'no-octal-escape': 2,
148     'no-path-concat': 2,
149     'no-proto': 2,
150     'no-redeclare': 2,
151     'no-regex-spaces': 2,
152     'no-return-assign': [
153       2, 'except-parens'
154     ],
155     'no-self-assign': 2,
156     'no-self-compare': 2,
157     'no-sequences': 2,
158     'no-shadow-restricted-names': 2,
159     'no-spaced-func': 2,
160     'no-sparse-arrays': 2,
161     'no-this-before-super': 2,
162     'no-throw-literal': 2,
163     'no-trailing-spaces': 2,
164     'no-undef': 2,
165     'no-undef-init': 2,
166     'no-unexpected-multiline': 2,
167     'no-unmodified-loop-condition': 2,
168     'no-unneeded-ternary': [
169       2, {
170         'defaultAssignment': false
171       }
172     ],
173     'no-unreachable': 2,
174     'no-unsafe-finally': 2,
175     'no-unused-vars': [
176       2, {
177         'vars': 'all',
178         'args': 'none'
179       }
180     ],
181     'no-useless-call': 2,
182     'no-useless-computed-key': 2,
183     'no-useless-constructor': 2,
184     'no-useless-escape': 0,
185     'no-whitespace-before-property': 2,
186     'no-with': 2,
187     'one-var': [
188       2, {
189         'initialized': 'never'
190       }
191     ],
192     'operator-linebreak': [
193       2,
194       'after', {
195         'overrides': {
196           '?': 'before',
197           ':': 'before'
198         }
199       }
200     ],
201     'padded-blocks': [
202       2, 'never'
203     ],
204     'quotes': [
205       2,
206       'single', {
207         'avoidEscape': true,
208         'allowTemplateLiterals': true
209       }
210     ],
211     'semi': [
212       2, 'never'
213     ],
214     'semi-spacing': [
215       2, {
216         'before': false,
217         'after': true
218       }
219     ],
220     'space-before-blocks': [
221       2, 'always'
222     ],
223     'space-before-function-paren': [
224       2, 'never'
225     ],
226     'space-in-parens': [
227       2, 'never'
228     ],
229     'space-infix-ops': 2,
230     'space-unary-ops': [
231       2, {
232         'words': true,
233         'nonwords': false
234       }
235     ],
236     'spaced-comment': [
237       2,
238       'always', {
239         'markers': [
240           'global',
241           'globals',
242           'eslint',
243           'eslint-disable',
244           '*package',
245           '!',
246           ','
247         ]
248       }
249     ],
250     'template-curly-spacing': [
251       2, 'never'
252     ],
253     'use-isnan': 2,
254     'valid-typeof': 2,
255     'wrap-iife': [
256       2, 'any'
257     ],
258     'yield-star-spacing': [
259       2, 'both'
260     ],
261     'yoda': [
262       2, 'never'
263     ],
264     'prefer-const': 2,
265     'no-debugger': process.env.NODE_ENV === 'production'
266       ? 2
267       : 0,
268     'object-curly-spacing': [
269       2,
270       'always', {
271         objectsInObjects: false
272       }
273     ],
274     'array-bracket-spacing': [2, 'never']
275   },
276   parserOptions: {
277     parser: "babel-eslint"
278   }
279 }

如果用VueCli 3.x版本,也可以放在package.json里。

posted @ 2019-05-06 14:39  dora_zc  阅读(3253)  评论(0编辑  收藏  举报