Configuration
Linting with Flint must be configured by at least one flint.config.* configuration file, in the root of a repository to be linted.
That file may be any extension recognized by your version of Node.js.
Flint configs must default-export the result of calling the defineConfig function imported from the flint package.
flint also exports a globs object for common file globs, as well as objects for each of the core plugins.
defineConfig
Section titled “defineConfig”Defines a new configuration for linting.
It takes in an object with one required property, use:
import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: ts.presets.logical, }, ],});The only required object property to pass to defineConfig is use, an array of definitions containing two properties:
files: glob pattern(s) describing which file(s) to lintrules: any number of rules to enable for those files
Any number of glob pattern(s) describing file(s) to lint.
This can be a string, any level deep array of strings, or an object containing exclude and include.
For example, this files selector matches all TypeScript test files by extension and in a directory:
import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ["src/**/*.test.*.ts", "test/**/*.ts"], rules: ts.presets.logical, }, ],});See the Node.js file system glob documentation for details on glob patterns.
exclude and include
Section titled “exclude and include”In addition to plain strings, files selectors can also be objects with two properties:
exclude: glob pattern(s) to not include in the files groupinclude: glob pattern(s) to include in the files group
For example, this files selector matches all TypeScript source files that don’t have a *.test.* extension:
import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: { exclude: "**/*.test.*", include: ts.files.all, }, rules: ts.presets.logical, }, ],});Any number of rule(s) to enable on the corresponding files.
These may be arrays of rules, such as from presets exported by plugins, and/or calls to plugin rules themselves.
For example, this rules entry enables all the recommended logical and stylistic TypeScript rules:
import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: [ts.presets.logical, ts.presets.stylistic], }, ],});Configuring Rules
Section titled “Configuring Rules”Rules can be configured or even disabled by calling to the rules method of their plugin.
That method takes in an object where the keys are rule names and values are what to do with the rule:
true: enable it (if it wasn’t already)false: disable it (if it was previously enabled)- Object containing options: enable it with those options
For example, this rules entry disables one rule and reconfigures another:
import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: [ ts.presets.logical, ts.presets.stylistic, ts.rules({ debuggerStatements: false, namespaceDeclarations: { allowDeclarations: true, }, }), ], }, ],});A helper object containing file selectors with dynamic computed values.
Currently it contains only one selector, all.
Includes all files previously selected by the configuration.
For example, this config enables the spelling plugin on all files that are being linted, which includes multiple languages:
import { spelling } from "@flint.fyi/plugin-spelling";import { defineConfig, globs, md, ts } from "flint";
export default defineConfig({ use: [ { files: md.files.all, rules: md.presets.logical, }, { files: ts.files.all, rules: [ts.presets.logical, ts.presets.stylistic], }, { files: globs.all, rules: spelling.presets.logical, }, ],});