ESLint plugin + shareable config for the Nullstack framework
# npm
$ npm add -D eslint-plugin-nullstack
# yarn
$ yarn add -D eslint-plugin-nullstack
Once the eslint-plugin-nullstack
package is installed, you can use it by specifying plugin:nullstack/recommended
in the extends
section of your ESLint configuration
// .eslintrc
{
"extends": "plugin:nullstack/recommended"
}
// package.json
"scripts": {
"lint": "eslint \"**/*.{js,jsx,ts,tsx,njs,nts}\" --fix"
}
// vscode - settings.json
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
You can override prettier
's default settings by updating the nullstack/prettier
rule
// .eslintrc
{
"extends": "plugin:nullstack/recommended",
"rules": {
"nullstack/prettier": [
"warn",
{
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"printWidth": 120
},
{
"usePrettierrc": false
}
]
}
}
IMPORTANT: Do not use
Prettier Formatter for Visual Studio Code
as this plugin uses a customprettier
implementation based oneslint-plugin-prettier
Main features:
- Recommended rules to help find possible logical errors in code
- Automatic organize imports
- Automatic remove unused imports
- Automatic code formatting (custom prettier implementation)
This plugin is based on the following plugins and configurations:
eslint:recommended
plugin:@typescript-eslint/recommended
eslint-plugin-import
eslint-plugin-import-helpers
eslint-plugin-prettier
eslint-plugin-react
eslint-plugin-unused-imports
eslint-plugin-sort-class-members
Nullstack rules:
nullstack/no-undef
- A custom implementation to support Nullstack inner componentsnullstack/prettier
- A custom implementation to support the rules: lines-between-class-members and padded-blocks (class only)nullstack/jsx-boolean-value
- Based onreact/jsx-boolean-value
nullstack/self-closing-comp
- Based onreact/self-closing-comp
nullstack/no-unused-imports
- Based onunused-imports/no-unused-imports
nullstack/no-unused-vars
- Based onunused-imports/no-unused-vars
nullstack/sort-class-members
- Based onsort-class-members/sort-class-members