README
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 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 |
.feature | Gherkin |
.js | JavaScript |
.mjs | JavaScript |
.ts | TypeScript |
It is fine to specify different types of source files in the same src
glob pattern(s), as long as
other configuration settings don't interfere.
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.
env
extends
globals
noInlineConfig
overrides
parser
parserOptions
plugins
processor
reportUnusedDisableDirectives
settings
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.