Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

fasttime/lint

Repository files navigation

@fasttime/lint · npm version

Universal linter with fasttime presets.

Usage

Plain usage:

exports.lint =
async () =>
{
    const { lint } = require('@fasttime/lint');

    await lint({ src, env, fix, globals, parserOptions, rules });
};

Usage with Gulp:

exports.lint =
() =>
{
    const { gulpLint } = require('@fasttime/lint');

    const stream = gulpLint({ src, env, fix, globals, parserOptions, rules });
    return stream;
};

It is also possible to specify a list of configurations, each targeting a different set of files.

await lint({ src: src1, ...config1 }, { src: src2, ...config2 });

or

const stream = gulpLint({ src: src1, ...config1 }, { src: src2, ...config2 });

Settings

src

The setting src is used to specify a glob pattern or a list of glob patterns that match the files to be linted. JavaScript, TypeScript and Gehrkin files are supported. The file type is inferred from the extension according to the following mapping.

Extension Type
.cjs JavaScript
.cts TypeScript
.feature Gherkin
.js JavaScript
.mjs JavaScript
.mts TypeScript
.ts TypeScript

fix

When set to true, linting problems are fixed automatically if possible.

JavaScript and TypeScript options

JavaScript and TypeScript are linted with ESLint. The following ESLint options are supported.

Additionally, the legacy option envs can be used instead of env to specify environments as a string or array of strings rather than with an object.

Gherkin options

Currently, the only specific option for Gherkin files is defaultDialectName, which can be a string specifing the keyword of a supported language. The default is English.