CLI
Flintβs CLI comes as part of the flint npm package.
You can run it with npx or an equivalent:
npx flintpnpx flintyarn dlx flint--cache-ignore
Section titled β--cache-ignoreβWhether to ignore any existing cache data on disk. This will cause a full re-lint of all linted files.
npx flint --cache-ignorepnpx flint --cache-ignoreyarn dlx flint --cache-ignoreEnables auto-fixing βfixesβ from rule reports.
npx flint --fixpnpx flint --fixyarn dlx flint --fixRule reports may include safe βfixerβ changes that show how to fix source code.
Adding --fix will instruct Flint to continuously re-run (up to 10 times), fixing code and re-linting files.
--fix-suggestions
Section titled β--fix-suggestionsβEnables auto-fixing any number of specific βsuggestionsβ from rule reports.
npx flint --fix-suggestions cspell:addWordToWordspnpx flint --fix-suggestions cspell:addWordToWordsyarn dlx flint --fix-suggestions cspell:addWordToWordsUnlike --fix, --fix-suggestions requires passing in explicit names of suggestions to apply.
Suggestion names are comprised of the rule name, and a suggestion ID, all joined by :.
Prints a help text dialog that explains options and links to this website.
npx flint --helppnpx flint --helpyarn dlx flint --help--interactive
Section titled β--interactiveβWhether to run Flint with an interactive βone file at a timeβ viewer.
npx flint --interactivepnpx flint --interactiveyarn dlx flint --interactiveFlintβs interactive CLI view can be controlled by using the arrow keys printed in the output:
π Displaying Flint reports in --interactive mode (file 1 of 2). [<] previous file [>] next file [q] quit
β./example.tsββ [forInArrays] For-in loops over arrays have surprising behavior that often leads to bugs.ββ 6:1 β for (const i in ["a", "b", "c"]) {β β ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ββ A for-in loop (`for (const i in o)`) iterates over all enumerable properties of an object, including those that are not array indices.β This can lead to unexpected behavior when used with arrays, as it may include properties that are not part of the array's numeric indices.β It also returns the index key (`i`) as a string, which is not the expected numeric type for array indices.ββ Suggestion: Use a construct more suited for arrays, such as a for-of loop (`for (const i of o)`).β β flint.fyi/rules/ts/forInArraysββ°βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Found 3 reports across 2 files.--presenter
Section titled β--presenterβWhich βpresenterβ to output results using: brief (default) or detailed.
npx flintpnpx flintyarn dlx flintThe brief presenter shows a terse output with just file locations, primary report messages, and report IDs.
Linting with flint.config.ts...
/Users/josh/repos/flint/packages/cli/src/presenters/getPresenterFactory.ts 6:1 For-in loops over arrays have surprising behavior that often leads to bugs. forInArrays
β Found 1 report across 1 file.The detailed presenter shows a rich formatted output containing full report messages and syntax locations.
Linting with flint.config.ts...β./packages/cli/src/presenters/getPresenterFactory.tsββ [forInArrays] For-in loops over arrays have surprising behavior that often leads to bugs.ββ 6:1 β for (const i in ["a", "b", "c"]) {β β ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ββ A for-in loop (`for (const i in o)`) iterates over all enumerable properties of an object, including those that are not array indices.β This can lead to unexpected behavior when used with arrays, as it may include properties that are not part of the array's numeric indices.β It also returns the index key (`i`) as a string, which is not the expected numeric type for array indices.ββ Suggestion: Use a construct more suited for arrays, such as a for-of loop (`for (const i of o)`).β β flint.fyi/rules/forInArraysββ°βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Found 1 report across 1 file.--skip-diagnostics
Section titled β--skip-diagnosticsβWhether to skip reporting language βdiagnosticsβ after linting.
npx flint --skip-diagnosticspnpx flint --skip-diagnosticsyarn dlx flint --skip-diagnosticsLanguage plugins such as are able to report additional checks from the languages after linting.
For example, Flintβs core TypeScript plugin reports TypeScript type errors (effectively running tsc --noEmit) by re-using the TypeScript type services used in linting.
--skip-diagnostics can be used to disable those checks.
You may wish to do this for performance and/or if you run tools like tsc separately from Flint.
--version
Section titled β--versionβPrints the current package version of Flint.
npx flint --versionpnpx flint --versionyarn dlx flint --version--watch
Section titled β--watchβWhether to keep the linting process running, re-linting files as they change.
npx flint --watchpnpx flint --watchyarn dlx flint --watchFlintβs --watch mode is similar to the watch mode in other developer tools CLIs such as tsc --watch, tsdown --watch, and vitest --watch.
It will lint files once on startup, then again whenever any linted files are changed on disk.