Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylelint-webpack-plugin

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylelint-webpack-plugin - npm Package Compare versions

Comparing version 2.2.2 to 3.0.0

14

declarations/index.d.ts

@@ -35,16 +35,2 @@ export default StylelintWebpackPlugin;

getContext(compiler: Compiler): string;
/**
* @param {Compiler} compiler
* @param {string[]} wanted
* @param {string[]} exclude
* @returns {string[]}
*/
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
/**
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
* @returns {string[]}
*/
getChangedFiles(
fileTimestamps: Map<string, 'ignore' | FileSystemInfoEntry | null>
): string[];
}

7

declarations/utils.d.ts
/**
* @param {string|(string|undefined)[]} files
* @param {string|string[]} files
* @param {string} context
* @returns {string[]}
*/
export function parseFiles(
files: string | (string | undefined)[],
context: string
): string[];
export function parseFiles(files: string | string[], context: string): string[];
/**

@@ -11,0 +8,0 @@ * @param {string|string[]} patterns

@@ -10,6 +10,6 @@ "use strict";

var _globby = _interopRequireDefault(require("globby"));
var _arrify = _interopRequireDefault(require("arrify"));
var _globby = _interopRequireDefault(require("globby"));
var _micromatch = require("micromatch");

@@ -26,3 +26,2 @@

// @ts-ignore
// @ts-ignore

@@ -93,4 +92,5 @@ /** @typedef {import('webpack').Compiler} Compiler */

const context = this.getContext(compiler);
const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
const options = { ...this.options,
exclude: (0, _utils.parseFiles)(this.options.exclude || ['**/node_modules/**', compiler.options.output.path], context),
exclude: (0, _utils.parseFiles)(this.options.exclude || excludeDefault, context),
extensions: (0, _arrify.default)(this.options.extensions),

@@ -123,3 +123,10 @@ files: (0, _utils.parseFiles)(this.options.files || '', context)

compilation.hooks.finishModules.tap(this.key, () => {
const files = this.getFiles(compiler, wanted, exclude);
const files = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles).filter(file => (0, _micromatch.isMatch)(file, wanted, {
dot: true
}) && !(0, _micromatch.isMatch)(file, exclude, {
dot: true
})) : _globby.default.sync(wanted, {
dot: true,
ignore: exclude
});

@@ -184,85 +191,3 @@ if (threads > 1) {

}
/**
* @param {Compiler} compiler
* @param {string[]} wanted
* @param {string[]} exclude
* @returns {string[]}
*/
// eslint-disable-next-line no-unused-vars
getFiles(compiler, wanted, exclude) {
// webpack 5
if (compiler.modifiedFiles) {
return Array.from(compiler.modifiedFiles).filter(file => (0, _micromatch.isMatch)(file, wanted, {
dot: true
}) && !(0, _micromatch.isMatch)(file, exclude, {
dot: true
}));
} // webpack 4
/* istanbul ignore next */
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
return this.getChangedFiles(compiler.fileTimestamps).filter(file => (0, _micromatch.isMatch)(file, wanted, {
dot: true
}) && !(0, _micromatch.isMatch)(file, exclude, {
dot: true
}));
}
return _globby.default.sync(wanted, {
dot: true,
ignore: exclude
});
}
/**
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
* @returns {string[]}
*/
/* istanbul ignore next */
getChangedFiles(fileTimestamps) {
/**
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
* @returns {Partial<number>}
*/
const getTimestamps = fileSystemInfoEntry => {
// @ts-ignore
if (fileSystemInfoEntry && fileSystemInfoEntry.timestamp) {
// @ts-ignore
return fileSystemInfoEntry.timestamp;
} // @ts-ignore
return fileSystemInfoEntry;
};
/**
* @param {string} filename
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
* @returns {boolean}
*/
const hasFileChanged = (filename, fileSystemInfoEntry) => {
const prevTimestamp = getTimestamps(this.prevTimestamps.get(filename));
const timestamp = getTimestamps(fileSystemInfoEntry);
return (prevTimestamp || this.startTime) < (timestamp || Infinity);
};
const changedFiles = [];
for (const [filename, timestamp] of fileTimestamps.entries()) {
if (hasFileChanged(filename, timestamp)) {
changedFiles.push(filename);
}
}
this.prevTimestamps = fileTimestamps;
return changedFiles;
}
}

@@ -269,0 +194,0 @@

@@ -14,13 +14,12 @@ "use strict";

var _arrify = _interopRequireDefault(require("arrify"));
var _normalizePath = _interopRequireDefault(require("normalize-path"));
var _arrify = _interopRequireDefault(require("arrify"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// @ts-ignore
// @ts-ignore
/**
* @param {string|(string|undefined)[]} files
* @param {string|string[]} files
* @param {string} context

@@ -30,6 +29,4 @@ * @returns {string[]}

function parseFiles(files, context) {
return (0, _arrify.default)(files).filter((
return (0, _arrify.default)(files).map((
/** @type {string} */
file) => typeof file === 'string').map((
/** @type {string} */
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));

@@ -36,0 +33,0 @@ }

{
"name": "stylelint-webpack-plugin",
"version": "2.2.2",
"version": "3.0.0",
"description": "A Stylelint plugin for webpack",

@@ -17,3 +17,3 @@ "license": "MIT",

"engines": {
"node": ">= 10.13.0"
"node": ">= 12.13.0"
},

@@ -47,12 +47,12 @@ "scripts": {

"stylelint": "^13.0.0",
"webpack": "^4.0.0 || ^5.0.0"
"webpack": "^5.0.0"
},
"dependencies": {
"@types/stylelint": "^13.13.0",
"arrify": "^2.0.1",
"jest-worker": "^27.0.2",
"@types/stylelint": "^13.13.1",
"arrify": "^3.0.0",
"jest-worker": "^27.0.6",
"globby": "^11.0.4",
"micromatch": "^4.0.4",
"normalize-path": "^3.0.0",
"schema-utils": "^3.0.0"
"schema-utils": "^3.1.0"
},

@@ -62,7 +62,7 @@ "devDependencies": {

"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@types/fs-extra": "^9.0.11",
"@types/micromatch": "^4.0.1",
"@types/fs-extra": "^9.0.12",
"@types/micromatch": "^4.0.2",
"@types/normalize-path": "^3.0.0",

@@ -72,21 +72,21 @@ "@types/webpack": "^5.28.0",

"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.2",
"babel-jest": "^27.0.6",
"chokidar": "^3.5.2",
"cross-env": "^7.0.3",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.28.0",
"del-cli": "^4.0.0",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"file-loader": "^6.2.0",
"fs-extra": "^9.1.0",
"husky": "^6.0.0",
"jest": "^27.0.4",
"lint-staged": "^10.5.4",
"fs-extra": "^10.0.0",
"husky": "^7.0.1",
"jest": "^27.0.6",
"lint-staged": "^11.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.1",
"prettier": "^2.3.2",
"standard-version": "^9.3.0",
"stylelint": "^13.13.1",
"typescript": "^4.3.2",
"webpack": "^5.39.0"
"typescript": "^4.3.5",
"webpack": "^5.44.0"
},

@@ -93,0 +93,0 @@ "keywords": [

@@ -16,6 +16,8 @@ <div align="center">

> A Stylelint plugin for webpack
This plugin uses [`stylelint`](https://stylelint.io/) that helps you avoid errors and enforce conventions in your styles.
## Install
## Getting Started
To begin, you'll need to install `stylelint-webpack-plugin`:
```bash

@@ -25,3 +27,3 @@ npm install stylelint-webpack-plugin --save-dev

**Note**: You also need to install `stylelint` from npm, if you haven't already:
**Note**: You also need to install `stylelint >= 13` from npm, if you haven't already:

@@ -32,6 +34,4 @@ ```bash

## Usage
Then add the plugin to your webpack config. For example:
In your webpack configuration:
```js

@@ -38,0 +38,0 @@ const StylelintPlugin = require('stylelint-webpack-plugin');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc