Skip to content

Commit 73a82b1

Browse files
committed
ci: mandatory eslint rules for build
This commit adds verification for statically identifiable definite errors. Sometimes global variables used will be falsely reported as undefined variables in which case the new file `mandatory.eslint.config.js` should be updated to include these definitions in the narrowest scope possible that has these definitions
1 parent 2ae0c12 commit 73a82b1

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

eslint/mandatory.eslint.config.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import tseslintPlugin from '@typescript-eslint/eslint-plugin';
2+
import { defineConfig } from 'eslint/config';
3+
import globals from 'globals';
4+
5+
const backendLanguageOptions = {
6+
globals: {
7+
// Current, intentionally supported globals
8+
extension: 'readonly',
9+
config: 'readonly',
10+
global_config: 'readonly',
11+
12+
// Older not entirely ideal globals
13+
use: 'readonly', // <-- older import mechanism
14+
def: 'readonly', // <-- older import mechanism
15+
kv: 'readonly', // <-- should be passed/imported
16+
ll: 'readonly', // <-- questionable
17+
18+
// Language/environment globals
19+
...globals.node,
20+
},
21+
};
22+
23+
export default defineConfig([
24+
{
25+
ignores: [
26+
'src/backend/src/modules/apps/AppInformationService.js', // TEMPORARY - SHOULD BE FIXED!
27+
'src/backend/src/services/worker/WorkerService.js', // TEMPORARY - SHOULD BE FIXED!
28+
'src/backend/src/public/**/*', // We may be able to delete this! I don't think it's used
29+
30+
// These files run in the worker environment, so these rules don't apply
31+
'src/backend/src/services/worker/dist/**/*.{js,cjs,mjs}',
32+
'src/backend/src/services/worker/src/**/*.{js,cjs,mjs}',
33+
'src/backend/src/services/worker/template/puter-portable.js',
34+
],
35+
},
36+
{
37+
plugins: {
38+
'@typescript-eslint': tseslintPlugin,
39+
},
40+
},
41+
{
42+
files: [
43+
'src/backend/**/*.{js,mjc,cjs}',
44+
'extensions/**/*.{js,mjc,cjs}',
45+
'src/backend-core-0/**/*.{js,mjc,cjs}',
46+
],
47+
ignores: [
48+
'src/backend/src/services/database/sqlite_setup/**/*.js',
49+
],
50+
rules: {
51+
'no-undef': 'error',
52+
},
53+
languageOptions: {
54+
...backendLanguageOptions,
55+
},
56+
},
57+
{
58+
files: [
59+
'src/backend/src/services/database/sqlite_setup/**/*.js',
60+
],
61+
rules: {
62+
'no-undef': 'error',
63+
},
64+
languageOptions: {
65+
globals: {
66+
read: 'readonly',
67+
write: 'readonly',
68+
log: 'readonly',
69+
...globals.node,
70+
},
71+
},
72+
},
73+
{
74+
files: [
75+
'src/backend/**/*.{ts}',
76+
'extensions/**/*.{ts}',
77+
'src/backend-core-0/**/*.{ts}',
78+
],
79+
rules: {
80+
'no-undef': 'error',
81+
},
82+
languageOptions: {
83+
...backendLanguageOptions,
84+
},
85+
},
86+
]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"start": "node ./tools/run-selfhosted.js",
4545
"prestart": "npm run build:ts",
4646
"dev": "npm run build:ts && DEVCONSOLE=1 node ./tools/run-selfhosted.js",
47-
"build": "npm run build:ts; cd src/gui; node ./build.js",
47+
"build": "npx eslint --quiet -c eslint/mandatory.eslint.config.js src/backend/src extensions && npm run build:ts && cd src/gui && node ./build.js",
4848
"check-translations": "node tools/check-translations.js",
4949
"prepare": "husky",
5050
"build:ts": "tsc",

0 commit comments

Comments
 (0)