Created
September 12, 2023 16:32
-
-
Save jgoux/e3110a846235f1a75408d3958dd3f9fc to your computer and use it in GitHub Desktop.
Strict and sensible ESLint, Prettier and TypeScript configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typescriptPlugin from "@typescript-eslint/eslint-plugin"; | |
import typescriptParser from "@typescript-eslint/parser"; | |
import prettierConfig from "eslint-config-prettier"; | |
import importPlugin from "eslint-plugin-import"; | |
import nodeImportPlugin from "eslint-plugin-node-import"; | |
import prettierPlugin from "eslint-plugin-prettier"; | |
import perfectionistPlugin from 'eslint-plugin-perfectionist'; | |
import unusedImportsPlugin from "eslint-plugin-unused-imports"; | |
import globals from "globals"; | |
export default [ | |
{ | |
files: ["**/*.@(js|jsx|ts|tsx)"], | |
ignores: [".dts/**"], | |
languageOptions: { | |
globals: { | |
...globals.browser, | |
...globals.node, | |
}, | |
parser: typescriptParser, | |
parserOptions: { | |
project: "./tsconfig.json", | |
}, | |
}, | |
plugins: { | |
"@typescript-eslint": typescriptPlugin, | |
import: importPlugin, | |
"node-import": nodeImportPlugin, | |
perfectionist: perfectionistPlugin, | |
prettier: prettierPlugin, | |
"unused-imports": unusedImportsPlugin, | |
}, | |
rules: { | |
...typescriptPlugin.configs["eslint-recommended"].rules, | |
...typescriptPlugin.configs["strict-type-checked"].rules, | |
...typescriptPlugin.configs["stylistic-type-checked"].rules, | |
...importPlugin.configs.recommended.rules, | |
...perfectionistPlugin.configs["recommended-natural"].rules, | |
"@typescript-eslint/array-type": ["error", { default: "generic" }], | |
"@typescript-eslint/consistent-type-imports": "error", | |
"@typescript-eslint/no-unused-vars": "off", | |
"import/consistent-type-specifier-style": ["error", "prefer-inline"], | |
"import/newline-after-import": "error", | |
"import/no-duplicates": ["error", { "prefer-inline": true }], | |
"import/no-unresolved": "off", | |
"node-import/prefer-node-protocol": "error", | |
"no-restricted-syntax": [ | |
"error", | |
{ | |
"selector": "TSEnumDeclaration", | |
"message": "Use const object instead of enum." | |
} | |
], | |
"perfectionist/sort-imports": ["error", { | |
...perfectionistPlugin.configs["recommended-natural"].rules["perfectionist/sort-imports"][1], | |
"newlines-between": "never", | |
"internal-pattern": ["#*", "#*/**"], | |
}], | |
"unused-imports/no-unused-imports": "error", | |
"unused-imports/no-unused-vars": ["error", { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }], | |
...prettierConfig.rules, | |
...prettierPlugin.configs.recommended.rules, | |
}, | |
}, | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"extends": [ | |
"@tsconfig/strictest", | |
"@tsconfig/node-lts" | |
], | |
"compilerOptions": { | |
"checkJs": false, | |
"composite": true, | |
"noEmit": false, | |
"emitDeclarationOnly": true, | |
"outDir": ".dts", | |
"customConditions": [ | |
"development" | |
], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment