Lynt has two main philosophies:
- Zero configuration by default. Out of the box, Lynt is a working linter and does not need any configuration. However, if you would like to add or remove rules from the default Lynt config, you have the option to do so.
- No style rules. Lynt is completely unopinionated when it comes to code style. It doesn't care whether or not you use semicolons, tabs or spaces, trailing commas, etc. Lynt only handles the error checking side of things and it leaves code style up to better-suited tools like
The real value of ESLint is in the non-style rules that prevent common errors.
– Nicholas C. Zakas, the creator of ESLint.
How It Works
It will know which linter to use as well as which rules/parsers/ignores/etc to apply based on the options you pass to it.
You can install the package locally for a single project:
$ npm install lynt --save-dev
Or you can install it globally (not recommended):
$ npm install lynt --global
If you want to lint all your project files, you can just run the
lynt command by itself.
Add a script to your
And then run the script in your terminal whenever you want to lint your code:
$ npm run lint
By default, folders like
node_modules are ignored.
If you only want to lint a subset of your project or individual files, you can pass globs:
You can use flags to add support for Flow, React, or TypeScript. For example, if you were using TypeScript and React, you can set your
lint script to:
You can see a full list of flags you can pass to
lynt in the CLI section.
Notes on TypeScript Usage
Lynt uses TSLint to lint TypeScript files, and some TSLint rules require type information about your project in order to work. If your
tsconfig.json file is in your root project folder, simply running
$ lynt --typescript
is enough. If your
tsconfig.json file is elsewhere (for example,
./config/tsconfig.json, you can point to it with a
$ lynt --typescript --project config
Note that if you only choose to lint a subset of your project by doing something like this:
$ lynt src/index.ts --typescript
You will be opting-out of some of the lint rules that require type information. You cannot lint a subset of your project and still specify a
--project at the same time.
One other thing to note is that the
--global flag are not supported with
--typescript, though you shouldn't really need them as things like globals should be set with type declaration files.
Lastly, just remember that if you have
lynt installed globally and are trying to use it with
--typescript, you will need to make sure that you have
typescript installed globally as well.
You can specify your Lynt configuration in one of three ways:
- Use CLI flags:
$ lynt --typescript --react --ignore tests/**/*.* --ignore fixtures/**/*.*
- Have a
"lynt"property in your
- Have a
.lyntrcfile in your root project folder:
If you want to turn off any of the default
lynt rules, or add your own custom rules, you can add a
rules object in your configuration.
Note that rule configuration cannot be done from the CLI, you must use a
lynt property in
package.json or use a
Disabling a default rule
You can set a value to
'off' to turn off a default rule.
Adding a rule
If you want to add a rule, you can set it to
on to use the rule's default setting, or set it to something more complicated.
Note: Style rules will still be ignored.
const default: lynt format =
lynt(files[, options]) => LyntResults
Uses ESLint or TSLint to lint a given set of files. Returns an array of LyntResult objects (see below to see its properties).
- files – A string or array of strings of file paths to lint. Required.
- options – A configuration object that lets you customize how lynt works. Optional
Here are the possible options you can pass:
See the CLI section to see a detailed description of what each option is for.
Example (no options):
Example (with options):
format(lintResults) => string
Formats an array of LyntResult objects (like the one returned from calling
lynt()) into a nice looking table.
- lintResults – An array of LyntResult objects.
I think these are awesome projects, and I have been a user of both. I definitely drew a lot of inspiration from them – however, one the main philosophies of
lynt was to be an error-checker, not a style guide. Both
xo are very opinionated when it comes to style.
xo is actually configurable, so you can manually remove all the style rules, but it is still troublesome when trying to use it with TypeScript and Flow – with
lynt it is seamless.
Are the current rules set in stone?
lynt is still in v0.X, the rules are considered to be tentative – there will probably be rules being added in and removed. Once Lynt reaches a point where most are happy with the rules, v1 will be released and rules will change a lot less often. New rules will be added as ESLint and TSLint introduce them though and will be introduced to Lynt as a major version upgrade. However, at no point will any style rules be accepted as part of
How can I voice my opinion about some of the linting rules?
The best way would be to open up a GitHub issue and people will be able to chime in with their opinion.
Are there any editor plugins?
Unfortunately, I haven't gotten around to trying to make any yet. I can definitely use some help in this department, so if anyone would like to try to make a plugin for their favorite editor it would be greatly appreciated! Also, please let me know if there's anything I can improve with the API in order to make editor integration easier.