stylelint-webpack-plugin 2.0.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -5
- package/declarations/StylelintError.d.ts +2 -0
- package/declarations/cjs.d.ts +3 -0
- package/declarations/getStylelint.d.ts +24 -0
- package/declarations/index.d.ts +49 -0
- package/declarations/linter.d.ts +34 -0
- package/declarations/options.d.ts +62 -0
- package/declarations/utils.d.ts +19 -0
- package/declarations/worker.d.ts +3 -0
- package/dist/StylelintError.js +6 -8
- package/dist/getStylelint.js +132 -0
- package/dist/index.js +224 -30
- package/dist/linter.js +286 -45
- package/dist/options.js +95 -0
- package/dist/options.json +38 -4
- package/dist/utils.js +71 -7
- package/dist/worker.js +50 -0
- package/package.json +47 -37
- package/CHANGELOG.md +0 -117
- package/dist/LintDirtyModulesPlugin.js +0 -74
- package/dist/getOptions.js +0 -45
package/dist/options.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getOptions = getOptions;
|
|
7
|
+
exports.getStylelintOptions = getStylelintOptions;
|
|
8
|
+
|
|
9
|
+
var _schemaUtils = require("schema-utils");
|
|
10
|
+
|
|
11
|
+
var _options = _interopRequireDefault(require("./options.json"));
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
|
|
17
|
+
/** @typedef {import("stylelint")} stylelint */
|
|
18
|
+
|
|
19
|
+
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
20
|
+
|
|
21
|
+
/** @typedef {import("stylelint").FormatterType} FormatterType */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} OutputReport
|
|
25
|
+
* @property {string=} filePath
|
|
26
|
+
* @property {FormatterType=} formatter
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} PluginOptions
|
|
31
|
+
* @property {string} context
|
|
32
|
+
* @property {boolean} emitError
|
|
33
|
+
* @property {boolean} emitWarning
|
|
34
|
+
* @property {string|string[]=} exclude
|
|
35
|
+
* @property {string|string[]} extensions
|
|
36
|
+
* @property {boolean} failOnError
|
|
37
|
+
* @property {boolean} failOnWarning
|
|
38
|
+
* @property {string|string[]} files
|
|
39
|
+
* @property {FormatterType} formatter
|
|
40
|
+
* @property {boolean} lintDirtyModulesOnly
|
|
41
|
+
* @property {boolean} quiet
|
|
42
|
+
* @property {string} stylelintPath
|
|
43
|
+
* @property {OutputReport} outputReport
|
|
44
|
+
* @property {number|boolean=} threads
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/** @typedef {Partial<PluginOptions & StylelintOptions>} Options */
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {Options} pluginOptions
|
|
51
|
+
* @returns {Partial<PluginOptions>}
|
|
52
|
+
*/
|
|
53
|
+
function getOptions(pluginOptions) {
|
|
54
|
+
const options = {
|
|
55
|
+
extensions: ['css', 'scss', 'sass'],
|
|
56
|
+
emitError: true,
|
|
57
|
+
emitWarning: true,
|
|
58
|
+
failOnError: true,
|
|
59
|
+
...pluginOptions,
|
|
60
|
+
...(pluginOptions.quiet ? {
|
|
61
|
+
emitError: true,
|
|
62
|
+
emitWarning: false
|
|
63
|
+
} : {})
|
|
64
|
+
}; // @ts-ignore
|
|
65
|
+
|
|
66
|
+
(0, _schemaUtils.validate)(_options.default, options, {
|
|
67
|
+
name: 'Stylelint Webpack Plugin',
|
|
68
|
+
baseDataPath: 'options'
|
|
69
|
+
});
|
|
70
|
+
return options;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @param {Options} pluginOptions
|
|
74
|
+
* @returns {Partial<StylelintOptions>}
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function getStylelintOptions(pluginOptions) {
|
|
79
|
+
const stylelintOptions = { ...pluginOptions
|
|
80
|
+
}; // Keep the files and formatter option because it is common to both the plugin and Stylelint.
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
files,
|
|
84
|
+
formatter,
|
|
85
|
+
...stylelintOnlyOptions
|
|
86
|
+
} = _options.default.properties; // No need to guard the for-in because schema.properties has hardcoded keys.
|
|
87
|
+
// eslint-disable-next-line guard-for-in
|
|
88
|
+
|
|
89
|
+
for (const option in stylelintOnlyOptions) {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
delete stylelintOptions[option];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return stylelintOptions;
|
|
95
|
+
}
|
package/dist/options.json
CHANGED
|
@@ -7,15 +7,23 @@
|
|
|
7
7
|
"type": "string"
|
|
8
8
|
},
|
|
9
9
|
"emitError": {
|
|
10
|
-
"description": "
|
|
10
|
+
"description": "The errors found will always be emitted, to disable set to `false`.",
|
|
11
11
|
"type": "boolean"
|
|
12
12
|
},
|
|
13
13
|
"emitWarning": {
|
|
14
|
-
"description": "
|
|
14
|
+
"description": "The warnings found will always be emitted, to disable set to `false`.",
|
|
15
15
|
"type": "boolean"
|
|
16
16
|
},
|
|
17
|
+
"exclude": {
|
|
18
|
+
"description": "Specify the files and/or directories to exclude. Must be relative to `options.context`.",
|
|
19
|
+
"anyOf": [{ "type": "string" }, { "type": "array" }]
|
|
20
|
+
},
|
|
21
|
+
"extensions": {
|
|
22
|
+
"description": "Specify extensions that should be checked.",
|
|
23
|
+
"anyOf": [{ "type": "string" }, { "type": "array" }]
|
|
24
|
+
},
|
|
17
25
|
"failOnError": {
|
|
18
|
-
"description": "Will cause the module build to fail if there are any errors,
|
|
26
|
+
"description": "Will cause the module build to fail if there are any errors, to disable set to `false`.",
|
|
19
27
|
"type": "boolean"
|
|
20
28
|
},
|
|
21
29
|
"failOnWarning": {
|
|
@@ -23,7 +31,7 @@
|
|
|
23
31
|
"type": "boolean"
|
|
24
32
|
},
|
|
25
33
|
"files": {
|
|
26
|
-
"description": "Specify
|
|
34
|
+
"description": "Specify directories, files, or globs. Must be relative to `options.context`. Directories are traveresed recursively looking for files matching `options.extensions`. File and glob patterns ignore `options.extensions`.",
|
|
27
35
|
"anyOf": [{ "type": "string" }, { "type": "array" }]
|
|
28
36
|
},
|
|
29
37
|
"formatter": {
|
|
@@ -41,6 +49,32 @@
|
|
|
41
49
|
"stylelintPath": {
|
|
42
50
|
"description": "Path to `stylelint` instance that will be used for linting.",
|
|
43
51
|
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
"outputReport": {
|
|
54
|
+
"description": "Write the output of the errors to a file, for example a `json` file for use for reporting.",
|
|
55
|
+
"anyOf": [
|
|
56
|
+
{
|
|
57
|
+
"type": "boolean"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"type": "object",
|
|
61
|
+
"additionalProperties": false,
|
|
62
|
+
"properties": {
|
|
63
|
+
"filePath": {
|
|
64
|
+
"description": "The `filePath` is relative to the webpack config: `output.path`.",
|
|
65
|
+
"anyOf": [{ "type": "string" }]
|
|
66
|
+
},
|
|
67
|
+
"formatter": {
|
|
68
|
+
"description": "You can pass in a different formatter for the output file, if none is passed in the default/configured formatter will be used.",
|
|
69
|
+
"anyOf": [{ "type": "string" }, { "instanceof": "Function" }]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"threads": {
|
|
76
|
+
"description": "Set to true for an auto-selected pool size based on number of cpus. Set to a number greater than 1 to set an explicit pool size. Set to false, 1, or less to disable and only run in main process.",
|
|
77
|
+
"anyOf": [{ "type": "number" }, { "type": "boolean" }]
|
|
44
78
|
}
|
|
45
79
|
}
|
|
46
80
|
}
|
package/dist/utils.js
CHANGED
|
@@ -4,19 +4,83 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseFiles = parseFiles;
|
|
7
|
-
exports.
|
|
7
|
+
exports.parseFoldersToGlobs = parseFoldersToGlobs;
|
|
8
|
+
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
9
|
+
|
|
10
|
+
var _path = require("path");
|
|
11
|
+
|
|
12
|
+
var _fs = require("fs");
|
|
13
|
+
|
|
14
|
+
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
8
15
|
|
|
9
16
|
var _arrify = _interopRequireDefault(require("arrify"));
|
|
10
17
|
|
|
11
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
19
|
|
|
13
|
-
//
|
|
14
|
-
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
// @ts-ignore
|
|
15
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {string|(string|undefined)[]} files
|
|
25
|
+
* @param {string} context
|
|
26
|
+
* @returns {string[]}
|
|
27
|
+
*/
|
|
16
28
|
function parseFiles(files, context) {
|
|
17
|
-
return (0, _arrify.default)(files).
|
|
29
|
+
return (0, _arrify.default)(files).filter((
|
|
30
|
+
/** @type {string} */
|
|
31
|
+
file) => typeof file === 'string').map((
|
|
32
|
+
/** @type {string} */
|
|
33
|
+
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));
|
|
18
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @param {string|string[]} patterns
|
|
37
|
+
* @param {string|string[]} extensions
|
|
38
|
+
* @returns {string[]}
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function parseFoldersToGlobs(patterns, extensions = []) {
|
|
43
|
+
const extensionsList = (0, _arrify.default)(extensions);
|
|
44
|
+
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', ''];
|
|
45
|
+
const extensionsGlob = extensionsList.map((
|
|
46
|
+
/** @type {string} */
|
|
47
|
+
extension) => extension.replace(/^\./u, '')).join(',');
|
|
48
|
+
return (0, _arrify.default)(patterns).map((
|
|
49
|
+
/** @type {string} */
|
|
50
|
+
pattern) => {
|
|
51
|
+
try {
|
|
52
|
+
// The patterns are absolute because they are prepended with the context.
|
|
53
|
+
const stats = (0, _fs.statSync)(pattern);
|
|
54
|
+
/* istanbul ignore else */
|
|
55
|
+
|
|
56
|
+
if (stats.isDirectory()) {
|
|
57
|
+
return pattern.replace(/[/\\]*?$/u, `/**${extensionsGlob ? `/*.${prefix + extensionsGlob + postfix}` : ''}`);
|
|
58
|
+
}
|
|
59
|
+
} catch (_) {// Return the pattern as is on error.
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return pattern;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param {string} _ key, but unused
|
|
68
|
+
* @param {any} value
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const jsonStringifyReplacerSortKeys = (_, value) => {
|
|
73
|
+
/**
|
|
74
|
+
* @param {{ [x: string]: any; }} sorted
|
|
75
|
+
* @param {string | number} key
|
|
76
|
+
*/
|
|
77
|
+
const insert = (sorted, key) => {
|
|
78
|
+
// eslint-disable-next-line no-param-reassign
|
|
79
|
+
sorted[key] = value[key];
|
|
80
|
+
return sorted;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return value instanceof Object && !(value instanceof Array) ? Object.keys(value).sort().reduce(insert, {}) : value;
|
|
84
|
+
};
|
|
19
85
|
|
|
20
|
-
|
|
21
|
-
return str.replace(/\\/g, '/');
|
|
22
|
-
}
|
|
86
|
+
exports.jsonStringifyReplacerSortKeys = jsonStringifyReplacerSortKeys;
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('stylelint')} Stylelint */
|
|
4
|
+
|
|
5
|
+
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
6
|
+
|
|
7
|
+
/** @typedef {import('./options').Options} Options */
|
|
8
|
+
Object.assign(module.exports, {
|
|
9
|
+
lintFiles,
|
|
10
|
+
setup
|
|
11
|
+
});
|
|
12
|
+
/** @type {Stylelint} */
|
|
13
|
+
|
|
14
|
+
let stylelint;
|
|
15
|
+
/** @type {Partial<StylelintOptions>} */
|
|
16
|
+
|
|
17
|
+
let linterOptions;
|
|
18
|
+
/**
|
|
19
|
+
* @param {Options} options
|
|
20
|
+
* @param {Partial<StylelintOptions>} stylelintOptions
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function setup(options, stylelintOptions) {
|
|
24
|
+
stylelint = require(options.stylelintPath || 'stylelint');
|
|
25
|
+
linterOptions = stylelintOptions;
|
|
26
|
+
return stylelint;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @param {string | string[]} files
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async function lintFiles(files) {
|
|
34
|
+
const {
|
|
35
|
+
results
|
|
36
|
+
} = await stylelint.lint({ ...linterOptions,
|
|
37
|
+
files
|
|
38
|
+
}); // Reset result to work with worker
|
|
39
|
+
|
|
40
|
+
return results.map(result => {
|
|
41
|
+
return {
|
|
42
|
+
source: result.source,
|
|
43
|
+
errored: result.errored,
|
|
44
|
+
ignored: result.ignored,
|
|
45
|
+
warnings: result.warnings,
|
|
46
|
+
deprecations: result.deprecations,
|
|
47
|
+
invalidOptionWarnings: result.invalidOptionWarnings
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
7
|
-
"author": "
|
|
8
|
-
"contributors": [
|
|
9
|
-
"Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>"
|
|
10
|
-
],
|
|
7
|
+
"author": "Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>",
|
|
11
8
|
"homepage": "https://github.com/webpack-contrib/stylelint-webpack-plugin",
|
|
12
9
|
"bugs": "https://github.com/webpack-contrib/stylelint-webpack-plugin/issues",
|
|
13
10
|
"funding": {
|
|
@@ -15,66 +12,79 @@
|
|
|
15
12
|
"url": "https://opencollective.com/webpack"
|
|
16
13
|
},
|
|
17
14
|
"main": "dist/cjs.js",
|
|
15
|
+
"types": "declarations/index.d.ts",
|
|
18
16
|
"engines": {
|
|
19
17
|
"node": ">= 10.13.0"
|
|
20
18
|
},
|
|
21
19
|
"scripts": {
|
|
22
20
|
"start": "npm run build -- -w",
|
|
23
|
-
"clean": "del-cli dist",
|
|
21
|
+
"clean": "del-cli dist declarations",
|
|
24
22
|
"prebuild": "npm run clean",
|
|
25
|
-
"build": "
|
|
23
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir declarations && prettier \"declarations/**/*.ts\" --write",
|
|
24
|
+
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
|
|
25
|
+
"build": "npm-run-all -p \"build:**\"",
|
|
26
26
|
"commitlint": "commitlint --from=master",
|
|
27
27
|
"security": "npm audit",
|
|
28
|
-
"lint:prettier": "prettier --list-different .",
|
|
28
|
+
"lint:prettier": "prettier -w --list-different .",
|
|
29
29
|
"lint:js": "eslint --cache .",
|
|
30
|
+
"lint:types": "tsc --pretty --noEmit",
|
|
30
31
|
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
31
|
-
"test:only": "cross-env NODE_ENV=test jest",
|
|
32
|
+
"test:only": "cross-env NODE_ENV=test jest --testTimeout=60000",
|
|
32
33
|
"test:watch": "npm run test:only -- --watch",
|
|
33
34
|
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
|
34
35
|
"pretest": "npm run lint",
|
|
35
36
|
"test": "npm run test:coverage",
|
|
36
|
-
"prepare": "npm run build",
|
|
37
|
-
"release": "standard-version"
|
|
38
|
-
"defaults": "webpack-defaults"
|
|
37
|
+
"prepare": "husky install && npm run build",
|
|
38
|
+
"release": "standard-version"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"declarations"
|
|
42
43
|
],
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"stylelint": "^13.0.0",
|
|
45
46
|
"webpack": "^4.0.0 || ^5.0.0"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
49
|
+
"@types/stylelint": "^13.13.0",
|
|
48
50
|
"arrify": "^2.0.1",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
+
"jest-worker": "^27.0.2",
|
|
52
|
+
"globby": "^11.0.4",
|
|
53
|
+
"micromatch": "^4.0.4",
|
|
54
|
+
"normalize-path": "^3.0.0",
|
|
55
|
+
"schema-utils": "^3.0.0"
|
|
51
56
|
},
|
|
52
57
|
"devDependencies": {
|
|
53
|
-
"@babel/cli": "^7.
|
|
54
|
-
"@babel/core": "^7.
|
|
55
|
-
"@babel/preset-env": "^7.
|
|
56
|
-
"@commitlint/cli": "^
|
|
57
|
-
"@commitlint/config-conventional": "^
|
|
58
|
-
"@
|
|
58
|
+
"@babel/cli": "^7.14.5",
|
|
59
|
+
"@babel/core": "^7.14.6",
|
|
60
|
+
"@babel/preset-env": "^7.14.5",
|
|
61
|
+
"@commitlint/cli": "^12.1.4",
|
|
62
|
+
"@commitlint/config-conventional": "^12.1.4",
|
|
63
|
+
"@types/fs-extra": "^9.0.11",
|
|
64
|
+
"@types/micromatch": "^4.0.1",
|
|
65
|
+
"@types/normalize-path": "^3.0.0",
|
|
66
|
+
"@types/webpack": "^5.28.0",
|
|
59
67
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
60
68
|
"babel-eslint": "^10.1.0",
|
|
61
|
-
"babel-jest": "^
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"del
|
|
65
|
-
"
|
|
66
|
-
"eslint
|
|
67
|
-
"eslint-
|
|
68
|
-
"eslint-plugin-import": "^2.
|
|
69
|
-
"file-loader": "^6.
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
69
|
+
"babel-jest": "^27.0.2",
|
|
70
|
+
"chokidar": "^3.5.2",
|
|
71
|
+
"cross-env": "^7.0.3",
|
|
72
|
+
"del": "^6.0.0",
|
|
73
|
+
"del-cli": "^3.0.1",
|
|
74
|
+
"eslint": "^7.28.0",
|
|
75
|
+
"eslint-config-prettier": "^8.3.0",
|
|
76
|
+
"eslint-plugin-import": "^2.23.4",
|
|
77
|
+
"file-loader": "^6.2.0",
|
|
78
|
+
"fs-extra": "^9.1.0",
|
|
79
|
+
"husky": "^6.0.0",
|
|
80
|
+
"jest": "^27.0.4",
|
|
81
|
+
"lint-staged": "^10.5.4",
|
|
73
82
|
"npm-run-all": "^4.1.5",
|
|
74
|
-
"prettier": "^2.
|
|
75
|
-
"standard-version": "^
|
|
76
|
-
"stylelint": "^13.
|
|
77
|
-
"
|
|
83
|
+
"prettier": "^2.3.1",
|
|
84
|
+
"standard-version": "^9.3.0",
|
|
85
|
+
"stylelint": "^13.13.1",
|
|
86
|
+
"typescript": "^4.3.2",
|
|
87
|
+
"webpack": "^5.39.0"
|
|
78
88
|
},
|
|
79
89
|
"keywords": [
|
|
80
90
|
"stylelint",
|
package/CHANGELOG.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
## [2.0.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.3...v2.0.0) (2020-05-04)
|
|
6
|
-
|
|
7
|
-
### ⚠ BREAKING CHANGES
|
|
8
|
-
|
|
9
|
-
* minimum supported Node.js version is `10.13`
|
|
10
|
-
* minimum supported stylelint version is `13.0.0`
|
|
11
|
-
|
|
12
|
-
### Bug Fixes
|
|
13
|
-
|
|
14
|
-
* avoiding https://github.com/mrmlnc/fast-glob/issues/158 ([#209](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/209)) ([14ae30d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/14ae30df8a6d6b629c4e1fa647b4c6989377aec8))
|
|
15
|
-
|
|
16
|
-
### [1.2.3](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.2...v1.2.3) (2020-02-08)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Performance
|
|
20
|
-
|
|
21
|
-
* require lint of stylelint only one time ([#207](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/207)) ([7e2495e](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/7e2495e6ba4d8cebb7f07cc9418020ea494670f8))
|
|
22
|
-
|
|
23
|
-
### [1.2.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.1...v1.2.2) (2020-02-08)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Bug Fixes
|
|
27
|
-
|
|
28
|
-
* replace back slashes on changed files ([#206](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/206)) ([7508028](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/7508028398d366c37d1a14e254baec9dc39b816c))
|
|
29
|
-
|
|
30
|
-
### [1.2.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.0...v1.2.1) (2020-01-16)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Bug Fixes
|
|
34
|
-
|
|
35
|
-
* compatibility stylelint v13 ([#204](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/204)) ([483be31](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/483be318450ec9a4f9eeb4bf1b1db203ba0c863d))
|
|
36
|
-
|
|
37
|
-
## [1.2.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.2...v1.2.0) (2020-01-13)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Features
|
|
41
|
-
|
|
42
|
-
* make possible to define official formatter as string ([#202](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/202)) ([8d6599c](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/8d6599c3f2f0e26d1515b01f6ecbafabeaa68fac))
|
|
43
|
-
* support stylelint v13 ([#203](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/203)) ([6fb31a3](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/6fb31a3931cb9d7cb0ce8cc99c9db28f928c82f4))
|
|
44
|
-
|
|
45
|
-
### [1.1.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.1...v1.1.2) (2019-12-04)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Bug Fixes
|
|
49
|
-
|
|
50
|
-
* support webpack 5 ([#199](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/199)) ([3d9e544](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/3d9e544f31172b7c01f4bd7c7254cfc7e38466c9))
|
|
51
|
-
|
|
52
|
-
### [1.1.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.0...v1.1.1) (2019-12-01)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Bug Fixes
|
|
56
|
-
|
|
57
|
-
* use hook `afterEmit` and emit error on catch ([17f7421](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/17f7421030e6a5b589b2cab015d9af80b868ca95))
|
|
58
|
-
|
|
59
|
-
## [1.1.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.4...v1.1.0) (2019-11-18)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
### Features
|
|
63
|
-
|
|
64
|
-
* support stylelint v12 ([#196](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/196)) ([aacf7ad](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/aacf7ad))
|
|
65
|
-
|
|
66
|
-
### [1.0.4](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.3...v1.0.4) (2019-11-13)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
### Bug Fixes
|
|
70
|
-
|
|
71
|
-
* hooks ([#195](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/195)) ([792fe19](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/792fe19))
|
|
72
|
-
|
|
73
|
-
### [1.0.3](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.2...v1.0.3) (2019-10-25)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
### Bug Fixes
|
|
77
|
-
|
|
78
|
-
* options variable ([#193](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/193)) ([3389aec](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/3389aec))
|
|
79
|
-
|
|
80
|
-
### [1.0.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.1...v1.0.2) (2019-10-07)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### Bug Fixes
|
|
84
|
-
|
|
85
|
-
* convert back-slashes ([#186](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/186)) ([41b0f53](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/41b0f53))
|
|
86
|
-
|
|
87
|
-
### [1.0.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.0...v1.0.1) (2019-09-30)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
### Bug Fixes
|
|
91
|
-
|
|
92
|
-
* compiler hooks ([aca2c1d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/aca2c1d))
|
|
93
|
-
|
|
94
|
-
## 1.0.0 (2019-09-30)
|
|
95
|
-
|
|
96
|
-
### Bug Fixes
|
|
97
|
-
|
|
98
|
-
* Handle compilation.fileTimestamps for webpack 4
|
|
99
|
-
* DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
|
|
100
|
-
* Update option `emitError`
|
|
101
|
-
* Update option `failOnError`
|
|
102
|
-
|
|
103
|
-
### Features
|
|
104
|
-
|
|
105
|
-
* Modernize project to latest defaults
|
|
106
|
-
* Validate options
|
|
107
|
-
* Support absolute paths in files array
|
|
108
|
-
* New option `stylelintPath`
|
|
109
|
-
* New option `emitWarning`
|
|
110
|
-
* New option `failOnWarning`
|
|
111
|
-
* New option `quiet`
|
|
112
|
-
|
|
113
|
-
### ⚠ BREAKING CHANGES
|
|
114
|
-
|
|
115
|
-
* Drop support for Node < 8.9.0
|
|
116
|
-
* Minimum supported `webpack` version is 4
|
|
117
|
-
* Minimum supported `stylelint` version is 9
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _micromatch = require("micromatch");
|
|
9
|
-
|
|
10
|
-
var _linter = _interopRequireDefault(require("./linter"));
|
|
11
|
-
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
class LintDirtyModulesPlugin {
|
|
17
|
-
constructor(lint, compiler, options) {
|
|
18
|
-
this.lint = lint;
|
|
19
|
-
this.compiler = compiler;
|
|
20
|
-
this.options = options;
|
|
21
|
-
this.startTime = Date.now();
|
|
22
|
-
this.prevTimestamps = {};
|
|
23
|
-
this.isFirstRun = true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
apply(compilation, callback) {
|
|
27
|
-
const fileTimestamps = compilation.fileTimestamps || new Map();
|
|
28
|
-
|
|
29
|
-
if (this.isFirstRun) {
|
|
30
|
-
this.isFirstRun = false;
|
|
31
|
-
this.prevTimestamps = fileTimestamps;
|
|
32
|
-
callback();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const dirtyOptions = { ...this.options
|
|
37
|
-
};
|
|
38
|
-
const glob = (0, _utils.replaceBackslashes)(dirtyOptions.files.join('|'));
|
|
39
|
-
const changedFiles = this.getChangedFiles(fileTimestamps, glob);
|
|
40
|
-
this.prevTimestamps = fileTimestamps;
|
|
41
|
-
|
|
42
|
-
if (changedFiles.length) {
|
|
43
|
-
dirtyOptions.files = changedFiles;
|
|
44
|
-
(0, _linter.default)(this.lint, dirtyOptions, this.compiler, callback);
|
|
45
|
-
} else {
|
|
46
|
-
callback();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getChangedFiles(fileTimestamps, glob) {
|
|
51
|
-
const getTimestamps = fileSystemInfoEntry => {
|
|
52
|
-
return fileSystemInfoEntry && fileSystemInfoEntry.timestamp ? fileSystemInfoEntry.timestamp : fileSystemInfoEntry;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const hasFileChanged = (filename, fileSystemInfoEntry) => {
|
|
56
|
-
const prevTimestamp = getTimestamps(this.prevTimestamps.get(filename));
|
|
57
|
-
const timestamp = getTimestamps(fileSystemInfoEntry);
|
|
58
|
-
return (prevTimestamp || this.startTime) < (timestamp || Infinity);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const changedFiles = [];
|
|
62
|
-
|
|
63
|
-
for (const [filename, timestamp] of fileTimestamps.entries()) {
|
|
64
|
-
if (hasFileChanged(filename, timestamp) && (0, _micromatch.isMatch)(filename, glob)) {
|
|
65
|
-
changedFiles.push((0, _utils.replaceBackslashes)(filename));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return changedFiles;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exports.default = LintDirtyModulesPlugin;
|
package/dist/getOptions.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = getOptions;
|
|
7
|
-
|
|
8
|
-
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
|
9
|
-
|
|
10
|
-
var _options = _interopRequireDefault(require("./options.json"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function getOptions(pluginOptions) {
|
|
15
|
-
const options = {
|
|
16
|
-
files: '**/*.s?(c|a)ss',
|
|
17
|
-
formatter: 'string',
|
|
18
|
-
stylelintPath: 'stylelint',
|
|
19
|
-
...pluginOptions
|
|
20
|
-
};
|
|
21
|
-
(0, _schemaUtils.default)(_options.default, options, {
|
|
22
|
-
name: 'Stylelint Webpack Plugin',
|
|
23
|
-
baseDataPath: 'options'
|
|
24
|
-
}); // eslint-disable-next-line
|
|
25
|
-
|
|
26
|
-
const stylelint = require(options.stylelintPath);
|
|
27
|
-
|
|
28
|
-
options.formatter = getFormatter(stylelint, options.formatter);
|
|
29
|
-
return options;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getFormatter({
|
|
33
|
-
formatters
|
|
34
|
-
}, formatter) {
|
|
35
|
-
if (typeof formatter === 'function') {
|
|
36
|
-
return formatter;
|
|
37
|
-
} // Try to get oficial formatter
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (typeof formatter === 'string' && typeof formatters[formatter] === 'function') {
|
|
41
|
-
return formatters[formatter];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return formatters.string;
|
|
45
|
-
}
|