Eslint in-house plugin to unify projects
Install eslint and dependencies eslint-plugin-brother-test-plugin
:
npm i eslint --save-dev
npm install eslint-plugin-brother-test-plugin --save-dev
# in case Vuejs 3 is used as UI framework
npm install @vue/eslint-config-typescript --save-dev
Add brother-test-plugin
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
There're several configs for different use
module.exports = {
extends: [
'plugin:brother-test-plugin/base', // using mostly for js files
'plugin:brother-test-plugin/ts-recommended', // using for ts files
'plugin:brother-test-plugin/jest-recommended', // using for ts test files (*.spec.ts, *.test.ts)
'plugin:brother-test-plugin/vue3-ui-recommended', // using for ui & component vue3 files
'plugin:brother-test-plugin/vue3-ts-recommended' // using for vue3 files with ts
]
}
const { commonRules } = require('eslint-plugin-brother-test-plugin')
module.exports = {
overrides: [
// overrding tests config & adding additional rules
{
extends: ['plugin:brother-test-plugin/jest-recommended'],
files: ['tests/**/*.ts'],
rules: {
'@typescript-eslint/no-misused-promises': 'off'
},
parserOptions: {
project: ['./tsconfig-tests.json']
}
},
// overrding vue files with ts config & adding additional rules
{
extends: ['plugin:brother-test-plugin/vue3-ts-recommended'],
files: ['ui/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-argument': 'off'
},
parserOptions: {
project: ['./tsconfig.json']
}
},
// overrding js files with common ruleset
{
extends: ['plugin:brother-test-plugin/ts-recommended'],
files: ['panelOS/**/*.*'],
rules: {
...commonRules.js,
}
}
]
}
Then configure the custom plugin rules you want to use under the rules section.
module.exports = {
rules: {
'brother-test-plugin/no-underscore': 'error'
}
}