The ESLint config used in GramyPomagamy (GSPS) TypeScript projects.
Run:
npm i -D @gramypomagamy/eslint-config
The base config is suitable for most projects with a single tsconfig.json
file.
Add a file called eslint.config.mjs
to your project root, and add this code there:
import { baseConfig } from '@gramypomagamy/eslint-config';
export default baseConfig;
The config creator allows you to create specific rules with custom paths to the files that would be linted and a custom path to a tsconfig.json
file.
Example usage:
import { ConfigCreator } from "@gramypomagamy/eslint-config";
const tsParser = ConfigCreator.createTsParser({
tsconfigFilePaths: [
"src/browser/tsconfig.json",
"src/extension/tsconfig.json",
],
});
const browserConfig = ConfigCreator.createBrowserRules({
folderPath: "src/browser",
});
const browserTsConfig = ConfigCreator.createNodeRules({
folderPath: "src/browser",
});
const extensionConfig = ConfigCreator.createNodeRules({
folderPath: "src/extension",
});
export default [
...tsParser,
...browserConfig,
...browserTsConfig,
...extensionConfig,
];
Install the ESLint Extension, then press Ctrl+Shift+P
(Cmd+Shift+P
on macOS), open Preferences: Open User Settings (JSON)
and add this to the file:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
This enable fix on save in VSCode for ESLint.
ESLint is enabled by default in WebStorm, the only recommended tweak is enabling "fix on save" in ESLint settings.