diff --git a/package-lock.json b/package-lock.json index 8eb920f..526708a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@amatlash/vite-plugin-stylelint", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 61cf8d0..4d5c17d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@amatlash/vite-plugin-stylelint", - "version": "1.1.0", + "version": "1.1.1", "description": "Vite 2 plugin to lint CSS with stylelint.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 643aa84..7ed57d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,9 @@ import type { Options } from './utils'; export default function viteStylelint(options: Options = {}): Plugin { const filter = createFilter( - options.include, - options.exclude || /node_modules/); + options.include || /.*\.(vue|scss|sass|css|postcss)/, + options.exclude || /node_modules/ + ); const outputCollection = createOutputCollection(); @@ -33,7 +34,10 @@ export default function viteStylelint(options: Options = {}): Plugin { outputCollection.delete(file); } }) - // .catch(error => console.error(error)) + .catch(error => { + this.warn('It looks like you configured bad include/exclude vite-plugin-stylelint options.'); + this.error(error); + }) .finally(() => { displayOutput(outputCollection); }) diff --git a/src/utils.ts b/src/utils.ts index edef840..6bc9dc6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,9 +14,15 @@ export function normalizePath(filePath: string): string { } export interface Options { - /** A single file, or array of files, to include when linting. */ + /** + * A single file, or array of files, to include when linting. + * @default /.*\.(vue|scss|sass|css|postcss)/ + */ include?: string | string[] | RegExp; - /** A single file, or array of files, to exclude when linting. */ + /** + * A single file, or array of files, to exclude when linting. + * @default /node_modules/ + */ exclude?: string | string[] | RegExp; }