mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 02:01:51 +00:00
Many configuration files in this repository were created a long time ago, then were modified as problems occurred. Now that there is TypeScript support, it makes sense to clean up this mess, at least by making small steps. This configuration is based on strict settings, but most of these are currently disabled - otherwise it would be too hard to work with existing JavaScript code. The downside of this change is pollution of files with warnings and errors, even though they are valid. - ESLint/TypeScript upgraded - TS configuration is now shared between arbitrary Node scripts, Gulp files and the Electron wrapper - A few eslint-disable comments are removed
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
import eslint from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import globals from "globals";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const baseConfig = tseslint.config(
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommendedTypeChecked,
|
|
// Enable type-aware linting
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
project: true,
|
|
// FIXME: Node.js 21.2.0 introduced import.meta.dirname
|
|
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url)),
|
|
},
|
|
},
|
|
},
|
|
// 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: {
|
|
// Mostly caused by JSDoc imports, so don't annoy with errors but keep
|
|
// a reminder!
|
|
"@typescript-eslint/no-unused-vars": "warn",
|
|
// 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,
|
|
files: ["*.ts", "*.js", "electron/**/*.ts", "electron/**/*.js", "gulp/**/*.ts", "gulp/**/*.js"],
|
|
ignores: ["gulp/preloader/*.js"],
|
|
})),
|
|
...runtimeConfig.map(config => ({
|
|
...config,
|
|
files: ["js", "ts", "jsx", "tsx"].map(ext => `src/**/*.${ext}`),
|
|
})),
|
|
];
|