lintf v0.3.0
Lintf
Linter and formatter runner for TypeScript, including configuration for ESLint (with typescript-eslint) and Prettier.
Installation
- Run
bun add -d lintf
.
Configuration
ESLint
Edit eslint.config.js
:
import config from 'lintf/eslint'
export default [config]
Overriding Rules
You can override eslint and typescript-eslint rules like this:
export default [config, { rules: { 'no-undef': 0 } }]
Prettier
Edit .prettierrc.json
:
{
"arrowParens": "always",
"bracketSameLine": true,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"endOfLine": "lf",
"experimentalTernaries": true,
"htmlWhitespaceSensitivity": "ignore",
"insertPragma": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "consistent",
"requirePragma": false,
"semi": false,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
Usage
Config File
You can create your own tool definitions in a .lintf.yml
file and add them to
the run
key, or override the default. Your config will be deep merged with the
default configuration.
See the Lintf Ruby
configuration for an explanation of how to use the .lintf.yml
file.
CLI
By default, Lintf checks all touched files in the current branch using
git diff origin/main
. You can change this behavior by passing the following
options to the CLI:
-a
: All files tracked by Git (usesgit ls-files
)-f
: Fix problems automatically (i.e. autocorrect)
Other flags are passed to the tools (e.g. lintf eslint --help
).
Examples
Here are some examples of how to use the CLI:
bunx lintf
: Run all tools, but only on touched filesbunx lintf -f
: Fix/format touched files with all toolsbunx lintf e p
: Run ESLint, then Prettierbunx lintf -a prettier
: Check all files with Prettierbunx lintf -fa p
: Format all files with Prettier
Here are some examples of how to override the default config with .lintf.yml
:
run: [eslint, my_custom_linter]
eslint:
fix: --fix-dry-run
my_custom_linter:
alias: mcl
run: bunx my_custom_linter --fail-fast
files: [md, yml]
This changes the ESLint autocorrection from the default --fix
to
--fix-dry-run
and defines a new tool that will be run by default (after
ESLint), or via bunx lintf my_custom_linter
or bunx lintf mcl
.
License
Lintf is released under the terms of the MIT License.