@arnaud-barre/eslint-config
v4.1.1
Published
TS-React focused eslint configuration
Downloads
2,385
Readme
eslint-config
Install
yarn add --dev eslint @arnaud-barre/eslint-config
// .eslintrc.cjs
module.exports = {
root: true,
extends: ["@arnaud-barre"],
};
// package.json
"scripts": {
"lint": "bun lint-ci --fix --cache",
"lint-ci": "eslint ./ --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
}
TS config
{
"include": ["**/*.ts", "**/*.tsx"],
"compilerOptions": {
"target": "ES2021",
"useDefineForClassFields": true,
"jsx": "react-jsx",
"module": "ESNext",
"lib": ["ES2021", "DOM", "DOM.Iterable"],
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
/* Linting */
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"noPropertyAccessFromIndexSignature": true
}
}
For Node projects
{
"include": ["**/*.ts"],
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"lib": ["ES2022"]
/* ... */
}
}
Adding local rules
Local rules are loaded from eslint-plugin/index.cjs
. Here is an example for an hypothetical "no-while" rule (that could simply be achieved by using the no-restricted-syntax rule)
// eslint-plugin/index.cjs
exports.rules = {
"no-while": {
meta: {
messages: { error: "Don't use while" },
type: "problem",
schema: [],
},
create: (context) => ({
WhileStatement(node) {
context.report({ node, messageId: "error" });
},
}),
},
};
// .eslintrc.cjs
module.exports = {
root: true,
extends: ["@arnaud-barre"],
rules: {
"@arnaud-barre/local/no-while": "warn",
},
};