我试图让我的Gruntfile.js使用grunt-stylint lint我的所有手写笔文件,但我无法听到我所有的手写笔文件,尤其是子目录中的那些。
这是我的样式结构:
- assets
- styles
bunch-of-files.styl
- components
even-more-files.styl
我用它来观看所有的手写笔文件:
watch: {
options: {
livereload: true,
},
pug: {
files: '**/*.pug',
tasks: ['puglint'],
options: {
livereload: true,
},
},
stylus: {
files: '**/*.styl',
tasks: ['stylint','stylus'],
},
scripts :{
files: 'assets/js/*.js',
tasks: ['concat'],
options: {
interrupt: false,
},
},
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
但是,stylint任务只会查看bunch-of-files
,而不是components/
文件夹:
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl']
},
其他我尝试过相同的结果:
stylint: {
options: {
config: '.stylintrc'
},
src: ['assets/styles/**/*.styl']
},
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/**/*.styl']
},
唯一有用的是这个,但现在只查看components/
目录:
stylint: {
options: {
config: '.stylintrc'
},
src: ['assets/styles/*/*.styl']
},
当我将其与之前的一个配对时,它只会读取第一个文件。例如,这只会读取bunch-of-files
。
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl','assets/styles/*/*.styl']
},
想法?
**
编辑w full gruntfile + package.json
Gruntfile:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
stylus: {
build: {
options: {
compress: false,
},
files: {
'public/css/main.css': 'assets/styles/main.styl',
}
}
},
concat: {
options: {
stripBanners: true,
},
basic: {
src: ['assets/js/*.js'],
dest: 'public/js/main.js',
},
},
jshint: {
all: ['Gruntfile.js', 'app.js', 'assets/**/*.js'],
options: {
force: true,
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
},
},
},
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl']
},
puglint: {
src: '**/*.pug',
options: {
requireClassLiteralsBeforeAttributes: true,
requireIdLiteralsBeforeAttributes: true,
requireLowerCaseAttributes: true,
requireLowerCaseTags: true,
validateIndentation: 2,
disallowDuplicateAttributes: true,
validateAttributeQuoteMarks: "\""
}
},
watch: {
options: {
livereload: true,
},
pug: {
files: '**/*.pug',
tasks: ['puglint'],
options: {
livereload: true,
},
},
stylus: {
files: '**/*.styl',
tasks: ['stylint','stylus'],
},
scripts :{
files: 'assets/js/*.js',
tasks: ['concat'],
options: {
interrupt: false,
},
},
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
nodemon: {
dev: {
script: 'app.js',
options: {
nodeArgs: ['--debug'],
env: {
PORT: '3000'
},
// omit this property if you aren't serving HTML files and
// don't want to open a browser tab on start
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
// refreshes browser when server reboots
nodemon.on('restart', function () {
// Delay before server listens on port
setTimeout(function() {
require('fs').writeFileSync('.rebooted', 'rebooted');
}, 1000);
});
}
}
}
},
concurrent: {
target: [['jshint', 'stylint', 'stylus', 'puglint', 'concat', 'watch'],'nodemon' ],
options: {
logConcurrentOutput: true
}
}
});
// Load plugins.
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-stylint');
grunt.loadNpmTasks('grunt-puglint');
// Default task(s).
grunt.registerTask('default', ['concurrent']);
};
的package.json
{
"name": "",
"version": "",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"font-awesome-stylus": "^4.5.0",
"grunt": "^0.4.5",
"grunt-cli": "^1.1.0",
"grunt-concurrent": "^2.2.1",
"grunt-contrib-concat": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-stylus": "^1.2.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-nodemon": "^0.4.1",
"grunt-puglint": "^1.0.0",
"grunt-stylint": "^0.1.2",
"mustache-express": "^1.2.2",
"open": "0.0.5",
"pug-lint-config-clock": "^1.1.1",
"reload": "^0.7.0",
"stylint": "^1.3.7"
},
"dependencies": {
"express": "^4.13.4",
"pug": "^2.0.0-beta2"
}
}