@pretty-cozy/eslint-config v0.7.1
@pretty-cozy/eslint-config
A pretty cozy collection of eslint rules.
Available configs
| config name | description |
|---|---|
baseJs | General config without a specific usage scope |
baseTs | Extends baseJs with typescript support |
react | React specific rule set |
preact | Preact specific rule set |
prettier | Enables prettier for eslint. |
tailwind | Tailwind css specific rule set |
Setup
- Install
eslintand the packagenpm i -D eslint @pretty-cozy/eslint-config Add an
eslint.config.mjsfile at the root directory of your project for configuration.import prettyCozy from "@pretty-cozy/eslint-config" export default [ ...prettyCozy.baseTs, ...prettyCozy.react, { // your additional configuration }, ...prettyCozy.prettier ]Add npm scripts to your
package.json:"scripts": { "lint": "eslint src", "lint:fix": "npx lint -- --fix" }
Usage
You can use eslint by executing the created scripts:
# Lint your code and print the result
npm run lint
# Autofix linter problems where possible
npm run lint:fixThe better setup
Above we created the eslint config by exporting an array.
However, @typescript-eslint provides an awesome utility to make writing configs a bit easier.
It adds a few quality of live improvements, like:
- nested config arrays (you no longer have to use the spread operator)
- correct types to provide auto-completion in your IDE
- a new
extendsfield, to adjust shared configs
See the related docs for more details.
Required changes:
- Install
typescript-eslintwhich exports the utilitynpm i -D typescript-eslint Use the exported config utility:
import prettyCozy from "@pretty-cozy/eslint-config" import ts from "typescript-eslint" export default ts.config( prettyCozy.baseTs, prettyCozy.react, { // your additional configuration }, prettyCozy.prettier, )
8 months ago
11 months ago
11 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 months ago
9 months ago
10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago