Eslint Config
Usage
- Install the library as a dev dependency alongside required dependencies using
yarn add -D
@rimac-technology/eslint-config
eslint
- Set up the minimal required configuration as displayed below
Minimal Required Configuration
- Create a new file in the
root
of the project called.eslintrc.json
- Place the following inside
{
"extends": ["@rimac-technology/eslint-config/core"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
}
- Make sure the
project
field (underparserOptions
) is pointing to the correct path to yourtsconfig.json
Optional Rulesets
Add the following ruleset to your .eslintrc.json
file under extends
section (example below)
"@rimac-technology/eslint-config/react"
"@rimac-technology/eslint-config/jest"
"@rimac-technology/eslint-config/type-graphql"
"@rimac-technology/eslint-config/mobx"
"@rimac-technology/eslint-config/testing-library"
*See usage below
Using Optional Rulesets
General
- The following is added to
.eslintrc.json
{
"extends": [
"@rimac-technology/eslint-config/core",
"@rimac-technology/eslint-config/<optional-ruleset-name>"
]
}
Testing Library
- If you prefer more granular control of which files
eslint-plugin-testing-library
considers for test files and lints you can change"files"
field.
{
"overrides": [
{
"files": [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"extends": ["@rimac-technology/eslint-config/testing-library"]
}
]
}
Turn on ESLint in your Project
Intellij
- Go to
File>Settings>Languages & Frameworks>Javascript>Code Quality Tools>ESLint
- Select
Automatic ESLint Configuration
- Check
run eslint --fix on save
- Apply settings
Overriding or Adding Custom Rules
Rules can be overridden by adding them to the rules
section in .eslintrc.json
like the following example
{
"extends": ["@rimac-technology/eslint-config/core"],
"rules": {
"space-infix-ops": "off"
}
}
Troubleshooting
Little fellow sometimes has problems. Here is how to help if it doesn't work:
- Delete
node_modules
- Go to
File>Invalidate Caches>Invalidate and Restart
- Reinstall dependencies
- Check if it works from the terminal. If it does, you IDE might be the problem here.
Testing Locally
In package.json
, specify the path to the folder where you cloned eslint-config
on your computer and place it instead of the version.
Then you can use it like any other lib.
- Default install
// Current
{
"@rimac-technology/eslint-config": "^19.0.0"
}
- Local install for testing
{
"@rimac-technology/eslint-config": "../eslint-config"
}