@sewing-kit/plugin-stylelint
This package provides a sewing-kit
plugin that runs stylelint as part of the sewing-kit lint
command.
Installation
yarn add @sewing-kit/plugin-stylelint --dev
stylelint()
The stylelint
function returns a sewing-kit
plugin. This plugin applies to the workspace, not an individual project.
import {createWorkspace} from '@sewing-kit/core';
import {stylelint} from '@sewing-kit/plugin-stylelint';
export default createWorkspace((workspace) => {
workspace.use(stylelint());
});
By default stylelint runs over css files. You can modify the files that are processed by passing in a files
glob to the plugin's options.
export default createWorkspace((workspace) => {
// Run stylelint on css and scss files
workspace.use(stylelint({files: '**/*.{css,scss}'}));
});
Hooks
This plugin adds the following hooks to LintWorkspaceConfigurationCustomHooks
:
-
stylelintFlags
: an object of options to convert into command line flags for theeslint
command. These options are camelcase versions of their CLI counterparts.import {createWorkspaceLintPlugin} from '@sewing-kit/core'; const plugin = createWorkspaceLintPlugin(({hooks}) => { hooks.configure.hook((configure) => { // Modify the maximum number of allowed warnings from the default of 0 configure.stylelintFlags?.hook((flags) => ({ ...flags, maxWarnings: 5, })); }); });