我已搜索但无法找到我的问题的答案。它说在 gulp-stylelint/index.js 文件中未定义“警告” - 澄清一下,我没有触及这个文件,因为它是一个“第 3 方”文件。无论是从命令行(gulp lint:css)还是在构建过程中运行它,我都会遇到相同的错误。
这是错误消息:
[vagrant@MCOM-DEV mcom-web]$ gulp lint:css
Building Project Version: undefined
Building for Environment: production
[15:24:48] Using gulpfile ~/Projects/menards.com/mcom-web/gulpfile.js
[15:24:48] Starting 'lint:css'...
/home/vagrant/Projects/menards.com/mcom-web/node_modules/gulp-stylelint/dist/index.js:177
var errors = res.results[0].warnings.filter(isErrorSeverity);
^
TypeError: Cannot read property 'warnings' of undefined
at /home/vagrant/Projects/menards.com/mcom-web/node_modules/gulp-stylelint/dist/index.js:177:39
at Array.reduce (<anonymous>)
at /home/vagrant/Projects/menards.com/mcom-web/node_modules/gulp-stylelint/dist/index.js:176:38
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
[vagrant@MCOM-DEV mcom-web]$
这是我在 package.json 文件中的依赖项:
"dependencies": {
"@babel/polyfill": "^7.0.0",
"axios": "^0.18.0",
"lodash": "^4.17.10",
"popper.js": "^1.14.4",
"uuid-js": "^0.7.5",
"vue": "^2.5.2",
"vuex": "^3.0.1"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/runtime": "^7.0.0",
"autoprefixer": "^9.1.5",
"babel-eslint": "^9.0.0",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^8.0.2",
"babel-plugin-dynamic-import-node": "^2.1.0",
"babel-plugin-transform-vue-jsx": "^4.0.1",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"cssnano": "^4.1.0",
"eslint": "^5.6.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.0",
"eslint-plugin-vue": "^4.0.0",
"friendly-errors-webpack-plugin": "^1.6.1",
"gulp": "^3.9.1",
"gulp-dart-sass": "^0.9.1",
"gulp-eslint": "^5.0.0",
"gulp-gzip": "^1.4.2",
"gulp-postcss": "^8.0.0",
"gulp-stylelint": "^7.0.0",
"gulp-tar": "^2.1.0",
"stylelint": "^9.6.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-order": "^1.0.0",
"stylelint-scss": "^3.3.1",
"uglifyjs-webpack-plugin": "^1.1.1",
"vue-loader": "^15.4.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^4.17.2",
"yargs": "^12.0.2"
},
这是我的 .stylelintrc 文件:
{
"extends": [
"stylelint-config-standard",
"stylelint-config-recommended-scss"
],
"plugins": [
"stylelint-order"
],
"rules": {
"at-rule-empty-line-before": null,
"at-rule-name-space-after": "always",
"at-rule-no-vendor-prefix": true,
"at-rule-semicolon-space-before": "never",
"block-closing-brace-empty-line-before": null,
"block-closing-brace-newline-after": null,
"block-opening-brace-space-before": null,
"color-named": "never",
"declaration-block-semicolon-newline-after": "always-multi-line",
"declaration-block-semicolon-newline-before": "never-multi-line",
"declaration-block-semicolon-space-after": "always-single-line",
"declaration-empty-line-before": null,
"declaration-no-important": true,
"font-family-name-quotes": "always-where-recommended",
"font-weight-notation": [
"numeric",
{
"ignore": [
"relative"
]
}
],
"function-url-no-scheme-relative": true,
"function-url-quotes": "always",
"length-zero-no-unit": true,
"max-empty-lines": 2,
"max-line-length": null,
"media-feature-name-no-vendor-prefix": true,
"media-feature-parentheses-space-inside": "never",
"media-feature-range-operator-space-after": "always",
"media-feature-range-operator-space-before": "never",
"no-descending-specificity": null,
"no-duplicate-selectors": true,
"number-leading-zero": "never",
"media-feature-name-no-unknown": [
true,
{
"ignoreMediaFeatureNames": [
"prefers-reduced-motion"
]
}
],
"order/properties-order": [
"position",
"top",
"right",
"bottom",
"left",
"z-index",
"box-sizing",
"display",
"flex",
"flex-align",
"flex-basis",
"flex-direction",
"flex-wrap",
"flex-flow",
"flex-shrink",
"flex-grow",
"flex-order",
"flex-pack",
"align-content",
"align-items",
"align-self",
"justify-content",
"order",
"float",
"width",
"min-width",
"max-width",
"height",
"min-height",
"max-height",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"overflow",
"overflow-x",
"overflow-y",
"-webkit-overflow-scrolling",
"-ms-overflow-x",
"-ms-overflow-y",
"-ms-overflow-style",
"columns",
"column-count",
"column-fill",
"column-gap",
"column-rule",
"column-rule-width",
"column-rule-style",
"column-rule-color",
"column-span",
"column-width",
"orphans",
"widows",
"clip",
"clear",
"font",
"font-family",
"font-size",
"font-style",
"font-weight",
"font-variant",
"font-size-adjust",
"font-stretch",
"font-effect",
"font-emphasize",
"font-emphasize-position",
"font-emphasize-style",
"font-smooth",
"src",
"hyphens",
"line-height",
"color",
"text-align",
"text-align-last",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-style",
"text-emphasis-position",
"text-decoration",
"text-indent",
"text-justify",
"text-outline",
"-ms-text-overflow",
"text-overflow",
"text-overflow-ellipsis",
"text-overflow-mode",
"text-shadow",
"text-transform",
"text-wrap",
"-webkit-text-size-adjust",
"-ms-text-size-adjust",
"letter-spacing",
"-ms-word-break",
"word-break",
"word-spacing",
"-ms-word-wrap",
"word-wrap",
"overflow-wrap",
"tab-size",
"white-space",
"vertical-align",
"direction",
"unicode-bidi",
"list-style",
"list-style-position",
"list-style-type",
"list-style-image",
"pointer-events",
"-ms-touch-action",
"touch-action",
"cursor",
"visibility",
"zoom",
"table-layout",
"empty-cells",
"caption-side",
"border-spacing",
"border-collapse",
"content",
"quotes",
"counter-reset",
"counter-increment",
"resize",
"user-select",
"nav-index",
"nav-up",
"nav-right",
"nav-down",
"nav-left",
"background",
"background-color",
"background-image",
"filter",
"background-repeat",
"background-attachment",
"background-position",
"background-position-x",
"background-position-y",
"background-clip",
"background-origin",
"background-size",
"border",
"border-color",
"border-style",
"border-width",
"border-top",
"border-top-color",
"border-top-style",
"border-top-width",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-bottom",
"border-bottom-color",
"border-bottom-style",
"border-bottom-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-radius",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-right-radius",
"border-bottom-left-radius",
"border-image",
"border-image-source",
"border-image-slice",
"border-image-width",
"border-image-outset",
"border-image-repeat",
"outline",
"outline-width",
"outline-style",
"outline-color",
"outline-offset",
"box-shadow",
"opacity",
"-ms-interpolation-mode",
"page-break-after",
"page-break-before",
"page-break-inside",
"transition",
"transition-delay",
"transition-timing-function",
"transition-duration",
"transition-property",
"transform",
"transform-origin",
"perspective",
"appearance",
"animation",
"animation-name",
"animation-duration",
"animation-play-state",
"animation-timing-function",
"animation-delay",
"animation-iteration-count",
"animation-direction",
"animation-fill-mode",
"fill",
"stroke"
],
"property-no-vendor-prefix": true,
"rule-empty-line-before": null,
"scss/dollar-variable-default": [
true,
{
"ignore": "local"
}
],
"selector-attribute-quotes": "always",
"selector-list-comma-newline-after": "always",
"selector-list-comma-newline-before": "never-multi-line",
"selector-list-comma-space-after": "always-single-line",
"selector-list-comma-space-before": "never-single-line",
"selector-max-attribute": 2,
"selector-max-class": 4,
"selector-max-combinators": 4,
"selector-max-compound-selectors": 4,
"selector-max-empty-lines": 1,
"selector-max-id": 0,
"selector-max-specificity": null,
"selector-max-type": 2,
"selector-max-universal": 1,
"selector-no-qualifying-type": true,
"selector-no-vendor-prefix": true,
"string-quotes": "double",
"value-keyword-case": "lower",
"value-list-comma-newline-after": "never-multi-line",
"value-list-comma-newline-before": "never-multi-line",
"value-list-comma-space-after": "always",
"value-no-vendor-prefix": true
}
}
这是我的 gulp 文件的相关部分:
'use strict';
const autoprefixer = require('autoprefixer');
const chalk = require('chalk');
const cssnano = require('cssnano');
const eslint = require('gulp-eslint');
const gulp = require('gulp');
const gzip = require('gulp-gzip');
const postcss = require('gulp-postcss');
const sass = require('gulp-dart-sass');
const spawn = require('child_process').spawn;
const stylelint = require('gulp-stylelint');
const tar = require('gulp-tar');
const webpack = require('webpack');
const pkg = require('./package');
const projectVersion = require('yargs').argv.projectVersion;
process.env.NODE_ENV = /.*SNAPSHOT.*/i.test(projectVersion)
? 'development'
: 'production';
console.log(`Building Project Version: ${JSON.stringify(projectVersion)}`);
console.log(`Building for Environment: ${process.env.NODE_ENV}`);
// Lint CSS files
gulp.task('lint:css', () => {
return gulp.src(`${__dirname}/src/scss/**/*.scss`)
.pipe(stylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
});
我确定这可能是我做错了什么,但我不知道是什么?