由于eslint语法检查工具限制很严格,导致启动项目是报错的解决办吧(使用cmder工具时发生的错误)

Vue取消eslint语法限制

由于vue对语法的限制过于严格,以至于在我第一次编译运行的时候一直编译失败,当然也包括一些警告:

当然,这里的警告我是知道怎么回事,但是这个错误我就很不明白了,原来eslint是一个语法检查工具,但是限制很严格,在我的vue文件里面很多空格都会导致红线警告(可以屏蔽),虽然可以屏蔽,但是在编译的时候老是会跳出来一堆警告出来,所以能完全关闭语法的限制是最好的了。

  以下是报错内容:

 1  
 2 ➜ my-project npm run dev
 3  
 4  
 5  
 6 > bblee-app@1.0.0 dev /Users/bianlifeng/my-project
 7  
 8 > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
 9  
10  
11  
12 95% emitting
13  
14  
15  
16 WARNING Compiled with 1 warnings 5:00:12 PM
17  
18  
19  
20  
21  
22 ✘ http://eslint.org/docs/rules/indent Expected indentation of 0 spaces but found 2
23  
24 src/components/Message.vue:46:1
25  
26 export default {
27  
28 ^
29  
30  
31  
32 ✘ http://eslint.org/docs/rules/indent Expected indentation of 2 spaces but found 4
33  
34 src/components/Message.vue:47:1
35  
36 data() {
37  
38 ^
39  
40  
41  
42 ✘ http://eslint.org/docs/rules/indent Expected indentation of 2 spaces but found 4
43  
44 src/components/Message.vue:65:1
45  
46 }
47  
48 ^
49  
50  
51  
52 ✘ http://eslint.org/docs/rules/indent Expected indentation of 0 spaces but found 2
53  
54 src/components/Message.vue:66:1
55  
56 }
57  
58 ^
59  
60  
61  
62  
63  
6423 problems (23 errors, 0 warnings)
65  
66  
67  
68  
69  
70 Errors:
71  
72 21 http://eslint.org/docs/rules/indent
73  
74 2 http://eslint.org/docs/rules/space-before-function-paren
75  
76  
77  
78 You may use special comments to disable some warnings.
79  
80 Use // eslint-disable-next-line to ignore the next line.
81  
82 Use /* eslint-disable */ to ignore all warnings in a file.

当然,这里的警告我是知道怎么回事,但是这个错误我就很不明白了,原来eslint是一个语法检查工具,但是限制很严格,在我的vue文件里面很多空格都会导致红线警告(可以屏蔽),虽然可以屏蔽,但是在编译的时候老是会跳出来一堆警告出来,所以能完全关闭语法的限制是最好的了。

关闭方法:

在build/webpack.base.conf.js文件中,注释或者删除掉:module->rules中有关eslint的规则

 1  
 2 module: {
 3  
 4 rules: [
 5  
 6 //...(config.dev.useEslint ? [createLintingRule()] : []), // 注释或者删除
 7  
 8 {
 9  
10 test: /\.vue$/,
11  
12 loader: 'vue-loader',
13  
14 options: vueLoaderConfig
15  
16 },
17  
18 ...
19  
20 }
21  
22 ]
23  
24 }

 

然后重新运行一下npm run dev或者构建命令 npm run build就可以啦。(本文转载)

posted @ 2019-05-17 14:49  微光半夏星  阅读(1928)  评论(0编辑  收藏  举报