2024-04-26 21:23:34 +00:00
|
|
|
import eslint from "@eslint/js";
|
|
|
|
|
import globals from "globals";
|
2024-06-18 11:43:55 +00:00
|
|
|
import tseslint from "typescript-eslint";
|
2024-04-26 21:23:34 +00:00
|
|
|
|
|
|
|
|
const baseConfig = tseslint.config(
|
|
|
|
|
eslint.configs.recommended,
|
|
|
|
|
...tseslint.configs.recommendedTypeChecked,
|
|
|
|
|
// Enable type-aware linting
|
|
|
|
|
{
|
|
|
|
|
languageOptions: {
|
|
|
|
|
parserOptions: {
|
|
|
|
|
project: true,
|
2025-04-10 20:22:03 +00:00
|
|
|
tsconfigRootDir: import.meta.dirname,
|
2024-04-26 21:23:34 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// Disable type-aware linting for JS files as it causes issues
|
|
|
|
|
{
|
|
|
|
|
files: ["*.js"],
|
|
|
|
|
...tseslint.configs.disableTypeChecked,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const nodeConfig = tseslint.config(...baseConfig, {
|
|
|
|
|
languageOptions: {
|
|
|
|
|
sourceType: "module",
|
|
|
|
|
globals: {
|
|
|
|
|
...globals.node,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const runtimeConfig = tseslint.config(...baseConfig, {
|
|
|
|
|
languageOptions: {
|
|
|
|
|
sourceType: "module",
|
|
|
|
|
globals: {
|
|
|
|
|
...globals.browser,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
2024-06-19 09:25:13 +00:00
|
|
|
// Mostly caused by JSDoc imports, disable for now
|
|
|
|
|
"@typescript-eslint/no-unused-vars": "off",
|
2024-04-26 21:23:34 +00:00
|
|
|
// FIXME: enforce when we're ready to
|
|
|
|
|
"prefer-const": "warn",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// I don't know what the ESLint devs were thinking about. This is just horrible
|
|
|
|
|
export default [
|
|
|
|
|
{
|
|
|
|
|
ignores: ["build/*"],
|
|
|
|
|
},
|
|
|
|
|
...nodeConfig.map(config => ({
|
|
|
|
|
...config,
|
2024-06-19 09:25:13 +00:00
|
|
|
files: ["*.{ts,js}", "{gulp,electron}/**/*.{ts,js}"],
|
2024-04-26 21:23:34 +00:00
|
|
|
})),
|
|
|
|
|
...runtimeConfig.map(config => ({
|
|
|
|
|
...config,
|
2024-06-19 09:25:13 +00:00
|
|
|
files: ["src/**/*.{ts,js,tsx,jsx}"],
|
2024-04-26 21:23:34 +00:00
|
|
|
})),
|
|
|
|
|
];
|