diff --git a/eslint/mandatory.eslint.config.js b/eslint/mandatory.eslint.config.js new file mode 100644 index 00000000..e3036508 --- /dev/null +++ b/eslint/mandatory.eslint.config.js @@ -0,0 +1,86 @@ +import tseslintPlugin from '@typescript-eslint/eslint-plugin'; +import { defineConfig } from 'eslint/config'; +import globals from 'globals'; + +const backendLanguageOptions = { + globals: { + // Current, intentionally supported globals + extension: 'readonly', + config: 'readonly', + global_config: 'readonly', + + // Older not entirely ideal globals + use: 'readonly', // <-- older import mechanism + def: 'readonly', // <-- older import mechanism + kv: 'readonly', // <-- should be passed/imported + ll: 'readonly', // <-- questionable + + // Language/environment globals + ...globals.node, + }, +}; + +export default defineConfig([ + { + ignores: [ + 'src/backend/src/modules/apps/AppInformationService.js', // TEMPORARY - SHOULD BE FIXED! + 'src/backend/src/services/worker/WorkerService.js', // TEMPORARY - SHOULD BE FIXED! + 'src/backend/src/public/**/*', // We may be able to delete this! I don't think it's used + + // These files run in the worker environment, so these rules don't apply + 'src/backend/src/services/worker/dist/**/*.{js,cjs,mjs}', + 'src/backend/src/services/worker/src/**/*.{js,cjs,mjs}', + 'src/backend/src/services/worker/template/puter-portable.js', + ], + }, + { + plugins: { + '@typescript-eslint': tseslintPlugin, + }, + }, + { + files: [ + 'src/backend/**/*.{js,mjc,cjs}', + 'extensions/**/*.{js,mjc,cjs}', + 'src/backend-core-0/**/*.{js,mjc,cjs}', + ], + ignores: [ + 'src/backend/src/services/database/sqlite_setup/**/*.js', + ], + rules: { + 'no-undef': 'error', + }, + languageOptions: { + ...backendLanguageOptions, + }, + }, + { + files: [ + 'src/backend/src/services/database/sqlite_setup/**/*.js', + ], + rules: { + 'no-undef': 'error', + }, + languageOptions: { + globals: { + read: 'readonly', + write: 'readonly', + log: 'readonly', + ...globals.node, + }, + }, + }, + { + files: [ + 'src/backend/**/*.{ts}', + 'extensions/**/*.{ts}', + 'src/backend-core-0/**/*.{ts}', + ], + rules: { + 'no-undef': 'error', + }, + languageOptions: { + ...backendLanguageOptions, + }, + }, +]); diff --git a/package.json b/package.json index c80a3839..d559ca78 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "start": "node ./tools/run-selfhosted.js", "prestart": "npm run build:ts", "dev": "npm run build:ts && DEVCONSOLE=1 node ./tools/run-selfhosted.js", - "build": "npm run build:ts; cd src/gui; node ./build.js", + "build": "npx eslint --quiet -c eslint/mandatory.eslint.config.js src/backend/src extensions && npm run build:ts && cd src/gui && node ./build.js", "check-translations": "node tools/check-translations.js", "prepare": "husky", "build:ts": "tsc",