eslint-config-bucketplace
ESlint shareable config for bucketplace
ESLint rules for bucketplace
projects.
Install
This will install all the dependencies required to use bucketplace
ESLint config.
$ npm install --save-dev eslint @bucketplace/eslint-config-bucketplace @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react
Usage
Add extends
field to .eslintrc
(create one if you haven't already):
{
"extends": [
"@bucketplace/eslint-config-bucketplace",
"@bucketplace/eslint-config-bucketplace/react",
"@bucketplace/eslint-config-bucketplace/typescript"
]
}
Or if you prefer package.json
:
{
"eslintConfig": {
"extends": [
"@bucketplace/eslint-config-bucketplace",
"@bucketplace/eslint-config-bucketplace/react",
"@bucketplace/eslint-config-bucketplace/typescript"
]
}
}
Available configs
You can use those configs in combination with the base config. All other configs are meant to be used with @bucketplace/eslint-config-bucketplace
config.
{
"extends": [
"@bucketplace/eslint-config-bucketplace",
"@bucketplace/eslint-config-bucketplace/node",
"@bucketplace/eslint-config-bucketplace/react",
"@bucketplace/eslint-config-bucketplace/typescript"
]
}
@bucketplace/eslint-config-bucketplace
- The base config for JavaScript projects.@bucketplace/eslint-config-bucketplace/node
- The config for Node.js environments.@bucketplace/eslint-config-bucketplace/react
- The config for React projects with support for JSX.@bucketplace/eslint-config-bucketplace/typescript
- The config for TypeScript projects.
Tips
Browser environment
If you are on browser environment, you may want to add browser
option to env
field in order to support browser-specific language features:
Please read this issue for more details.
{
"env": {
"browser": true
}
}
Globals
Sometimes you need to have global variables for special cases (e.g. refering external libraries). In this case, you can configure global variables inside of your config file, set globals
property to an object containing keys named for each of the global variables you want to use. This will prevent ESLint from complaining about the use of global variables. It basically tells ESLint that "these variables are populated in global
already, so do not warn about their usage".
{
"globals": {
"$": "readonly"
}
}
The property accepts a string
value of writable
and readonly
, which controls whether the key is allowed to be overwritten or not.
Please refer to the official ESLint documentation for more details.
Using script
source type
The base config enables modules
syntax by default. Add next to your config if you want to disable the behavior (e.g. for project scripts):
{
"parserOptions": {
"sourceType": "script"
}
}
Using ES5 instead of ES2015+
This is not generally recommended, but you can fallback to ES5 by adding next to your config if needed. This will switch ESLint environment to ES5:
{
"env": {
"es6": false
},
"parserOptions": {
"ecmaVersion": 5
}
}
Note: However, ESLint might still show errors since this shareable config is not configured to support ES5 in mind, so it may not work as expected. You can safely disable the rules manually if it complains.
More details
You can find more details about ESLint configuration here.
License
UNLICENSED