Answer the question
In order to leave comments, you need to log in
The linter doesn't work referring to incorrect syntax in index.js, what's wrong there?
I can't figure out what's going on. installed stylelint ( https://www.npmjs.com/package/gulp-stylelint ). I'm trying to start but nothing works
D:\untitled\node_modules\stylelint\lib\index.js:33
);
^
SyntaxError: Unexpected token )
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\untitled\node_modules\gulp-stylelint\src\index.js:5:28)
at Module._compile (module.js:571:32)
'use strict';
const checkAgainstRule = require('./utils/checkAgainstRule');
const createPlugin = require('./createPlugin');
const createStylelint = require('./createStylelint');
const formatters = require('./formatters');
const postcssPlugin = require('./postcssPlugin');
const report = require('./utils/report');
const requireRule = require('./requireRule');
const ruleMessages = require('./utils/ruleMessages');
const rules = require('./rules');
const standalone = require('./standalone');
const validateOptions = require('./utils/validateOptions');
/**
* TODO TYPES change any to appropriated options
* @type {import('postcss').Plugin<any> & Partial<import('stylelint').StylelintPublicAPI>}
*/
const api = postcssPlugin;
const requiredRules = rules.reduce(
/**
* @param {{[k: string]: any}} acc
* @param {string} cur
* @return {{[k: string]: any}}
*/
(acc, cur) => {
acc[cur] = requireRule(cur);
return acc;
},
{},
); ---- тут ошибка
api.utils = {
report,
ruleMessages,
validateOptions,
checkAgainstRule,
};
api.lint = standalone;
api.rules = requiredRules;
api.formatters = formatters;
api.createPlugin = createPlugin;
api.createLinter = createStylelint;
module.exports = api;
let gulp = require('gulp');
const sass = require('gulp-sass');
const less = require('gulp-less');
const stylus = require('gulp-stylus');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('autoprefixer');
const browserSync = require('browser-sync').create();
const postcss = require('gulp-postcss');
//const cssnano = require('cssnano');
//const short = require('postcss-short');
const beautify = require('gulp-beautify');
//const sassLint = require('gulp-sass-lint');
const gulpStylelint = require('gulp-stylelint');
//sass
gulp.task('itsass', function() {
return gulp.src('./scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(postcss([
autoprefixer(),
//cssnano(),
//short(),
]))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css/'))
.pipe(browserSync.reload({
stream: true,
}));
});
//less
gulp.task('itless', function() {
return gulp.src('./less/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css/'))
.pipe(browserSync.reload({
stream: true,
}));
});
//stylus
gulp.task('itstylus', function() {
return gulp.src('./stylus/*.styl')
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css/'))
.pipe(browserSync.reload({
stream: true,
}));
});
//server
gulp.task('serve', function() {
browserSync.init({
server: {
basedir: './',
},
port: 3000,
});
});
function browRe() {
return browserSync.reload();
}
gulp.task('beautify', function() {
return gulp
.src('./css/*.css')
.pipe(beautify.css({indent_size: 2}))
.pipe(gulp.dest('./css/'));
});
//gulp.task('sass', function() {
// return gulp.src('./scss/*.scss')
// .pipe(sassLint({
// options: {
// formatter: 'stylish',
// 'merge-default-rules': false
// },
// files: {ignore: '**/*.scss'},
// rules: {
// 'no-ids': 1,
// 'no-mergeable-selectors': 0
// },
// configFile: 'config/other/.sass-lint.yml'
// }))
// .pipe(sassLint.format())
// .pipe(sassLint.failOnError())
// .pipe(gulp.dest('./'));
//});
//watch
gulp.task('watche', function() {
gulp.watch('./scss/*.scss', gulp.series('itsass'));
gulp.watch('./less/*.less', gulp.series('itless'));
gulp.watch('./stylus/*.styl', gulp.series('itstylus'));
gulp.watch('./*.html', browRe);
gulp.watch('.js/*.js', browRe);
gulp.watch('.php/*.php', browRe);
});
gulp.task('lint-css', function () {
return gulp
.src('src/**/*.css')
.pipe(gulpStylelint({
reporters: [{
formatter: 'string',
console: true
}]
}));
});
//build
gulp.task('default', gulp.parallel('serve', 'beautify', 'lint-css', 'watche'));
{
"extends":["stylelint-config-standard", "stylelint-config-recess-order"],
"rules": {
"indentation": 2,
"string-quotes": "single",
"declaration-colon-space-before": "never",
"declaration-colon-space-after": "never",
"rule-empty-line-before": "never",
"media-feature-range-operator-space-before": "never",
"media-feature-range-operator-space-after": "never",
"media-feature-colon-space-before": "never",
"media-feature-colon-space-after": "never"
}
}
Answer the question
In order to leave comments, you need to log in
Check the version of NodeJS installed on your machine ( node -v
).
Most likely, this version is outdated and you need to install a newer one. The current LTS version is 12.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question