# stylelint4b

NPM license (opens new window) NPM version (opens new window)

stylelint (opens new window) which works in browsers.

# Installation

npm install stylelint4b

# Simple Usage

Some of the stylelint - Node.js API (opens new window) are available in the browser.

const stylelint4b = require("stylelint4b");

const result = await stylelint4b.lint({
  code: `
a {
    color: red
}
`,
  codeFilename: "a.css",
  config: {
    extends: "stylelint-config-standard"
  },
  fix: true
});

const warnings = resultObject.results[0].warnings;
const output = resultObject.output;

# Additional APIs Provided by stylelint4b

stylelint4b also provides some APIs needed to run on browsers.

# stylelint4b/alias

Define an alias to resolve dependencies in the configuration and options.

const stylelint4b = require("stylelint4b");
const alias = require("stylelint4b/alias");

// Defines the dependency module used in the configuration.
await alias.defineAliases({
  "stylelint-scss": import("stylelint-scss"),
  "stylelint-config-recommended-scss": import(
    "stylelint-config-recommended-scss"
  )
});

const result = await stylelint4b.lint({
  code: `
a {
    color: red
}
`,
  codeFilename: "a.scss",
  config: {
    extends: "stylelint-config-recommended-scss"
  }
});

# alias.defineAliases(aliases)

Define aliases to resolve dependencies in the configuration and options.

Parameter Type Require Description
aliases { [moduleId: string]: any } ⭕️ Dependency modules definition with alias as key.

# alias.defineAlias(moduleId, moduleObject)

Define an alias to resolve dependency in the configuration and options.

Parameter Type Require Description
moduleId string ⭕️ The alias key for the dependency module.
moduleObject any ⭕️ Dependency module.