[英]Multiple eslintrc in grunt pointing to different folder
I have folder structure like below and using eslint I am validating my syntax rules . 我具有如下所示的文件夹结构,并使用eslint来验证语法规则。
I have a grunt file which runs eslint by default to all folder below src . 我有一个grunt文件,默认情况下,该文件在src下面的所有文件夹中运行eslint。 But now I have got new scenario where I need to run few more rules to one specific folder mddx .
但是现在有了新的场景,我需要对一个特定的文件夹mddx运行更多规则。 Along With default rules mddx should run with more rules .
除默认规则外,mddx应该与更多规则一起运行。
I know we can have multiple .eslintrc.json file , but how to configure in gruntfile.js with two task , both doing eslint but rules are diffrent. 我知道我们可以有多个.eslintrc.json文件,但是如何通过两个任务在gruntfile.js中进行配置,这两个任务都是eslint,但是规则是不同的。 Also pointing folder is different.
另外指向文件夹也不同。
parent
|
|
|------src
| +mund
| |
| |--<jsfiles>
| +mddx
| |
| |--<jsfiles>
.eslintrc.json
|
|
gruntfile.js
|
gruntfile.js gruntfile.js
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
eslint: {
options: {
config: '.eslintrc.json',
reset: false
},
target: {
src: [
'src/**/*.js'
]
}
}
});
grunt.registerTask('default', ['eslint']);
};
I got answer so posting it . 我得到了答案,所以发布了它。 Created .eslintrc.json file specific to folder and divided eslint into two sub task .
创建特定于文件夹的.eslintrc.json文件,并将eslint分为两个子任务。 Both has different configuration and points to different rule and folder.
两者都有不同的配置,并且指向不同的规则和文件夹。
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
eslint: {
default: {
options: {
configFile: '.eslintrc.json',
reset: false
},
src: [
'src/**/*.js'
]
},
mddx: {
options: {
configFile: 'src/mddx/.eslintrc.json',
reset: false
},
src: [
'src/mddx/**/*.js'
]
}
}
});
grunt.registerTask('default', ['eslint']);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.