我已经在我的本地系统上安装了 node,gulp 并尝试使用 gulp 使用 css lint。下面是我的代码。
common.scss 文件
dd {
margin: 0;
}
gulp/config.js
scss: {
source: '/web/assets/scss/**/*.scss',
destination: '/web/assets/css',
options: {
outputStyle: 'compressed'
},
linting: {
config: path.resolve(__dirname, '.scss-lint.yml')
}
},
.scss-lint.yml 文件
# Default application configuration that all configurations inherit from.
scss_files: "**/*.scss"
plugin_directories: ['.scss-linters']
# List of gem names to load custom linters from (make sure they are already
# installed)
plugin_gems: []
# Default severity of all linters.
severity: warning
linters:
Indentation:
enabled: true
allow_non_nested_indentation: false
character: space # or 'tab'
width: 2
scss.js 文件
const application = require('../application'),
autoprefixer = require('gulp-autoprefixer'),
csso = require('gulp-csso'),
gulp = require('gulp'),
gulpif = require('gulp-if'),
linter = require('gulp-scss-lint'),
scss = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps');
const linterOptions = application.config().scss.linting;
linterOptions.config = application.path(linterOptions.config);
console.log("----------------------------------");
console.log(application.config().scss.source);
console.log("----------------------------------");
module.exports = function() {
return gulp.src(application.path(application.config().scss.source))
.pipe(linter({'maxBuffer': 9999999 * 1024}))
.pipe(linter(linterOptions))
.pipe(gulpif(application.mode() === 'development' && !application.isWatchTask(), linter.failReporter()))
.pipe(gulpif(application.mode() === 'development', sourcemaps.init()))
.pipe(scss(application.config().scss.options))
.on('error', scss.logError)
.pipe(gulpif(application.mode() === 'development', sourcemaps.write()))
.pipe(gulpif(application.mode() === 'production', autoprefixer(application.config().autoprefixer)))
.pipe(gulpif(application.mode() === 'production', csso()))
.pipe(gulp.dest(application.path(application.config().scss.destination)))
.pipe(application.browserSyncInstance().stream());
};
当我运行命令“ gulp scss
”时,它显示以下错误:
[14:51:51] 1 issues found in /var/www/html/limited/vendor/freewheel/freewheel-theme/web/assets/scss/common.scss
[14:51:51] common.scss:3 [W] Indentation: Line should be indented with spaces, not tabs
(node:22150) Warning: a promise was created in a handler at var/www/html/limited/node_modules/gulp-scss-lint/src/index.js:30:18 but was not returned from it
at new Promise (/var/www/html/limited/node_modules/bluebird/js/release/promise.js:79:10)
[14:51:51] 1 issues found in /var/www/html/limited/vendor/freewheel/freewheel-theme/web/assets/scss/common.scss
[14:51:51] common.scss:3 [W] Indentation: Line should be indented with spaces, not tabs
Fatal Error in plugin "gulp-scss-lint"
Message:
Error in plugin "gulp-scss-lint"
Message:
ScssLint failed for: common.scss