@illumini/eslint-config v0.7.0
eslint-config
This package provides Illumini's base ESLint configuration.
Pairs well with our Prettier configuration.
Table of Contents
Installation
This package has several peer dependencies.
Run npm info "@illumini/eslint-config@latest" peerDependencies to list the peer dependencies and versions.
Install all dependencies
Option 1: With
npxnpx install-peerdeps --dev @illumini/eslint-configNote:
npxis a package runner that comes with npm 5.2 and higher that makes installing peer dependencies easierOption 2: Without
npxnpm install --save-dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-import # or yarn add --dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-import
Create an
.eslintrcfile at the root of your project with the following:{ "extends": "@illumini" }
Configurations
We export four ESLint configurations for your usage:
Default Config
npm install --save-dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-importIn your .eslintrc:
{
"extends": "@illumini"
}NOTE: Make sure to specify your environment based on your project
TypeScript Config
Includes everything in the default config, plus environment specification and typescript-specific rules with
npm install --save-dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-import typescript @typescript-eslint/parser @typescript-eslint/eslint-pluginIn your .eslintrc:
{
"extends": "@illumini/eslint-config/typescript"
}React Config
Includes everything in the default and TypeScript config, plus environment specification and react-specific rules with
npm install --save-dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-import eslint-plugin-react-hooks typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-jsx-a11yIn your .eslintrc:
{
"extends": "@illumini/eslint-config/react"
}React Native Config
Includes everything in the default, TypeScript and React config, plus environment specification and react-native specific rules with
npm install --save-dev @illumini/eslint-config eslint babel-eslint prettier eslint-config-prettier eslint-plugin-import eslint-plugin-react-hooks typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-jsx-a11y @react-native-community/eslint-configIn your .eslintrc:
{
"extends": "@illumini/eslint-config/react-native"
}Specifying Environments
Our default config purposefully does not specify a certain environment as to not make any assumptions about your project. The only environment we do specify be default is es6. You can see all the default settings here.
Therefore, you should specify your project's environment yourself in your ESLint config. For example:
{
"extends": "@illumini",
"env": {
"browser": true,
"node": true
}
}View all available environments in the ESLint Docs
Editor Integration & Autoformatting
Once you've installed the config, you probably want your editor to lint and fix your code for you.
VS Code
- Install the ESLint extension:
View → Extensionsthen find and install ESLint - Reload the editor
In your VS Code user settings
Code/File → Preferences → SettingsorCMD/CTRL + ,click the{}icon in the top right corner to modify yoursettings.jsonfile"eslint.alwaysShowStatus": true, // An array of language identifiers specify the files to be validated "eslint.validate": [ { "language": "html", "autoFix": true }, { "language": "javascript", "autoFix": true }, { "language": "javascriptreact", "autoFix": true }, { "language": "typescript", "autoFix": true }, { "language": "typescriptreact", "autoFix": true } ], // Turn off prettier extension for js, jsx, ts, tsx files since we're handling that with ESLint "prettier.disableLanguages": [ "javascript", "javascriptreact", "typescript", "typescriptreact" ],
Pre-commit Hook
As another line of defence, if you want ESLint to automatically fix your errors on commit, you can use lint-staged with husky, which manages git hooks.
npm install --save-dev lint-staged huskyIn your
package.json:{ "lint-staged": { "*.js": ["eslint --fix"] }, "husky": { "hooks": { "pre-commit": "lint-staged" } } }
Publishing to npm
Read npm's docs on How to Update a Package.
npm login- Make sure you're logged into illumini's npm account with the credentials from 1pass.
npm whoamiwill tell you if you're already logged in.
- Make sure you're logged into illumini's npm account with the credentials from 1pass.
npm version <update_type>update_typecan bepatch,minor, ormajor. If you don't know which one to use, read up about semantic versioning.
npm publish
Overriding Rules
If you'd like to override any rules, you can add the rules to your .eslintrc file.
{
"extends": "@illumini",
"rules": {
"no-console": "off"
}
}5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago