Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
295327e
chore: update plugin
ricardogobbosouza May 24, 2021
504c065
test: fix output report
ricardogobbosouza May 24, 2021
39c2254
test: fix
ricardogobbosouza May 24, 2021
d329340
test: fix
ricardogobbosouza May 24, 2021
35d4a01
test: fix
ricardogobbosouza May 24, 2021
23e4cdd
test: fix
ricardogobbosouza May 24, 2021
194a896
test: fix
ricardogobbosouza May 24, 2021
2f8d14b
test: skip watch test for now
ricardogobbosouza May 24, 2021
f91662e
ci: update node version
ricardogobbosouza May 24, 2021
1a241ca
ci: update node version
ricardogobbosouza May 24, 2021
512daca
fix: threads
ricardogobbosouza May 25, 2021
961f0c6
ci: disable temporarly windows
ricardogobbosouza May 25, 2021
f62e993
style: formatting
ricardogobbosouza May 25, 2021
2bd268b
style: formatting
ricardogobbosouza May 26, 2021
9269bd1
ci: debug on windows
ricardogobbosouza May 26, 2021
c4715e7
fix: always normalize path
ricardogobbosouza May 26, 2021
b05095e
style: formatting
ricardogobbosouza May 26, 2021
23ee709
test: normalize path
ricardogobbosouza May 26, 2021
fe6501f
ci: enable ubuntu-latest and macos-latest
ricardogobbosouza May 26, 2021
9ca2c72
test: watch
ricardogobbosouza May 26, 2021
c330c7b
style: use `fs-extra`
ricardogobbosouza May 26, 2021
89cee0a
style: formatting
ricardogobbosouza May 26, 2021
72d763b
test: fix watch test
ricardogobbosouza May 26, 2021
072ca04
test: fix
ricardogobbosouza May 26, 2021
582aadb
test: debug watch
ricardogobbosouza May 26, 2021
d97651d
test: fix
ricardogobbosouza May 26, 2021
1dc3719
fix: get files on watch mode
ricardogobbosouza May 26, 2021
aa2eb3f
fix: get files
ricardogobbosouza May 26, 2021
1b7c611
fix: get files using `fast-glob`
ricardogobbosouza May 26, 2021
c455ea4
fix: export
ricardogobbosouza May 26, 2021
e49b73e
test: increase coverage
ricardogobbosouza May 26, 2021
04f5a13
test: fix context path
ricardogobbosouza May 26, 2021
2d04ecc
fix: changed files
ricardogobbosouza May 26, 2021
4b1a00a
test: skip watch
ricardogobbosouza May 26, 2021
3a67d1f
test: increase coverage
ricardogobbosouza May 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
rules: {
'global-require': 'off',
'import/no-dynamic-require': 'off',
},
};
8 changes: 4 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fetch-depth: 0

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}

Expand All @@ -43,8 +43,8 @@ jobs:
- name: Lint
run: npm run lint

#- name: Security audit
# run: npm run security
- name: Security audit
run: npm run security

- name: Check commit message
uses: wagoid/commitlint-github-action@v1
Expand All @@ -68,7 +68,7 @@ jobs:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,26 @@ Specify the config file location to be used by `stylelint`.

A string indicating the root of your files.

### `exclude`

- Type: `String|Array[String]`
- Default: `'node_modules'`

Specify the files and/or directories to exclude. Must be relative to `options.context`.

### `extensions`

- Type: `String|Array[String]`
- Default: `['css', 'scss', 'sass']`

Specify extensions that should be checked.

### `files`

- Type: `String|Array[String]`
- Default: `'**/*.(s(c|a)ss|css)'`
- Default: `null`

Specify the glob pattern for finding files. Must be relative to `options.context`.
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`.

### `fix`

Expand Down Expand Up @@ -96,6 +110,13 @@ Lint only changed files, skip lint on start.

Path to `stylelint` instance that will be used for linting.

### `threads`

- Type: `Boolean | Number`
- Default: `false`

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.

### Errors and Warning

**By default the plugin will auto adjust error reporting depending on stylelint errors/warnings counts.**
Expand All @@ -106,21 +127,21 @@ You can still force this behavior by using `emitError` **or** `emitWarning` opti
- Type: `Boolean`
- Default: `false`

Will always return errors, if set to `true`.
The errors found will always be emitted, to disable set to `false`.

#### `emitWarning`

- Type: `Boolean`
- Default: `false`

Will always return warnings, if set to `true`.
The warnings found will always be emitted, to disable set to `false`.

#### `failOnError`

- Type: `Boolean`
- Default: `false`

Will cause the module build to fail if there are any errors, if set to `true`.
Will cause the module build to fail if there are any errors, to disable set to `false`.

#### `failOnWarning`

Expand All @@ -136,6 +157,22 @@ Will cause the module build to fail if there are any warnings, if set to `true`.

Will process and report errors only and ignore warnings, if set to `true`.

#### `outputReport`

- Type: `Boolean|Object`
- Default: `false`

Write the output of the errors to a file, for example a `json` file for use for reporting.
The `filePath` is relative to the webpack config: `output.path`.
You can pass in a different formatter for the output file, if none is passed in the default/configured formatter will be used.

```js
{
filePath: 'path/to/file';
formatter: 'json';
}
```

## Changelog

[Changelog](CHANGELOG.md)
Expand Down
64 changes: 0 additions & 64 deletions declarations/LintDirtyModulesPlugin.d.ts

This file was deleted.

32 changes: 2 additions & 30 deletions declarations/StylelintError.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,2 @@
/** @typedef {import('stylelint').LintResult} LintResult */
/** @typedef {import('./getOptions').Options} Options */
export default class StylelintError extends Error {
/**
* @param {Options} options
* @param {Array<LintResult>} messages
* @returns {StylelintError}
*/
static format(
{ formatter }: Options,
messages: Array<LintResult>
): StylelintError;
/**
* @param {Partial<string>} messages
*/
constructor(messages: Partial<string>);
}
export type LintResult = import('stylelint').LintResult;
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files: string | string[];
formatter: TimerHandler;
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
stylelintPath: string;
};
export default StylelintError;
declare class StylelintError extends Error {}
3 changes: 2 additions & 1 deletion declarations/cjs.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
declare const _exports: typeof import('.').default;
declare const _exports: typeof plugin.default;
export = _exports;
import plugin = require('./index');
32 changes: 0 additions & 32 deletions declarations/getOptions.d.ts

This file was deleted.

47 changes: 47 additions & 0 deletions declarations/getStylelint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @typedef {import('stylelint')} Stylelint */
/** @typedef {import('stylelint').LintResult} LintResult */
/** @typedef {import('./options').Options} Options */
/** @typedef {() => Promise<void>} AsyncTask */
/** @typedef {(files: string|string[]) => Promise<LintResult[]>} LintTask */
/** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
/** @typedef {{stylelint: Stylelint, lintFiles: LintTask, cleanup: AsyncTask, threads: number, }} Linter */
/**
* @param {Options} options
* @returns {Linter}
*/
export function loadStylelint(options: Options): Linter;
/**
* @param {string|undefined} key
* @param {number} poolSize
* @param {Options} options
* @returns {Linter}
*/
export function loadStylelintThreaded(
key: string | undefined,
poolSize: number,
options: Options
): Linter;
/**
* @param {string|undefined} key
* @param {Options} options
* @returns {Linter}
*/
export default function getStylelint(
key: string | undefined,
{ threads, ...options }: Options
): Linter;
export type Stylelint = typeof import('stylelint');
export type LintResult = import('stylelint').LintResult;
export type Options = import('./options').Options;
export type AsyncTask = () => Promise<void>;
export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
export type Worker = JestWorker & {
lintFiles: LintTask;
};
export type Linter = {
stylelint: Stylelint;
lintFiles: LintTask;
cleanup: AsyncTask;
threads: number;
};
import JestWorker from 'jest-worker';
36 changes: 33 additions & 3 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
export default StylelintWebpackPlugin;
export type Compiler = import('webpack').Compiler;
/** @typedef {import('webpack').Compiler} Compiler */
export type Module = import('webpack').Module;
export type Options = import('./options').Options;
export type FileSystemInfoEntry = Partial<
| {
timestamp: number;
}
| number
>;
declare class StylelintWebpackPlugin {
constructor(options?: {});
options: import('./getOptions').Options;
/**
* @param {Options} options
*/
constructor(options?: Options);
key: string;
options: Partial<import('./options').PluginOptions>;
/**
* @param {Compiler} compiler
*/
run(compiler: Compiler): Promise<void>;
startTime: number;
prevTimestamps: Map<any, any>;
/**
* @param {Compiler} compiler
* @returns {void}
Expand All @@ -15,4 +32,17 @@ declare class StylelintWebpackPlugin {
* @returns {string}
*/
getContext(compiler: Compiler): string;
/**
* @param {Compiler} compiler
* @param {Module} module
* @returns {string[]}
*/
getFiles({ fileTimestamps }: Compiler, { buildInfo }: Module): string[];
/**
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
* @returns {string[]}
*/
getChangedFiles(
fileTimestamps: Map<string, 'ignore' | FileSystemInfoEntry | null>
): string[];
}
Loading