Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 56eda37

Browse files
authored
Merge pull request #1575 from TriliumNext/chore_eslint-formatting
chore: use eslint for formatting and replace dprint
2 parents a8319fc + ce340b2 commit 56eda37

File tree

7 files changed

+94
-194
lines changed

7 files changed

+94
-194
lines changed

.dprint.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"editorconfig.editorconfig",
55
"vitest.explorer",
66
"ms-playwright.playwright",
7-
"tobermory.es6-string-html"
7+
"tobermory.es6-string-html",
8+
"dbaeumer.vscode-eslint"
89
]
910
}

eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export default tseslint.config(
2424
"@typescript-eslint/no-unused-vars": [
2525
"error",
2626
{
27-
"argsIgnorePattern": "^_",
28-
"varsIgnorePattern": "^_",
27+
argsIgnorePattern: "^_",
28+
varsIgnorePattern: "^_"
2929
}
3030
]
3131
}
@@ -35,6 +35,7 @@ export default tseslint.config(
3535
"build/*",
3636
"dist/*",
3737
"docs/*",
38+
"demo/*",
3839
"libraries/*",
3940
"src/public/app-dist/*",
4041
"src/public/app/doc_notes/*"

eslint.format.config.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import stylistic from "@stylistic/eslint-plugin";
2+
import tsParser from "@typescript-eslint/parser";
3+
4+
// eslint config just for formatting rules
5+
// potentially to be merged with the linting rules into one single config,
6+
// once we have fixed the majority of lint errors
7+
8+
// Go to https://eslint.style/rules/default/${rule_without_prefix} to check the rule details
9+
export const stylisticRules = {
10+
"@stylistic/indent": [ "error", 4 ],
11+
"@stylistic/quotes": [ "error", "double", { avoidEscape: true, allowTemplateLiterals: "always" } ],
12+
"@stylistic/semi": [ "error", "always" ],
13+
"@stylistic/quote-props": [ "error", "consistent-as-needed" ],
14+
"@stylistic/max-len": [ "error", { code: 100 } ],
15+
"@stylistic/comma-dangle": [ "error", "never" ],
16+
"@stylistic/linebreak-style": [ "error", "unix" ],
17+
"@stylistic/array-bracket-spacing": [ "error", "always" ],
18+
"@stylistic/object-curly-spacing": [ "error", "always" ],
19+
"@stylistic/padded-blocks": [ "error", { classes: "always" } ]
20+
};
21+
22+
export default [
23+
{
24+
files: [ "**/*.{js,ts,mjs,cjs}" ],
25+
languageOptions: {
26+
parser: tsParser
27+
},
28+
plugins: {
29+
"@stylistic": stylistic
30+
},
31+
rules: {
32+
...stylisticRules
33+
}
34+
},
35+
{
36+
ignores: [
37+
"build/*",
38+
"dist/*",
39+
"docs/*",
40+
"demo/*",
41+
"libraries/*",
42+
// TriliumNextTODO: check if we want to format packages here as well - for now skipping it
43+
"packages/*",
44+
"src/public/app-dist/*",
45+
"src/public/app/doc_notes/*"
46+
]
47+
}
48+
];

package-lock.json

Lines changed: 35 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
"test:integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",
6060
"test:integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",
6161
"dev:watch-dist": "tsx ./bin/watch-dist.ts",
62-
"dev:format-check": "dprint check",
63-
"dev:format-fix": "dprint fmt",
62+
"dev:format-check": "eslint -c eslint.format.config.js .",
63+
"dev:format-fix": "eslint -c eslint.format.config.js . --fix",
6464
"dev:linter-check": "eslint .",
6565
"dev:linter-fix": "eslint . --fix",
6666
"chore:update-build-info": "tsx bin/update-build-info.ts",
@@ -174,6 +174,7 @@
174174
"@mind-elixir/node-menu": "1.0.5",
175175
"@playwright/test": "1.51.1",
176176
"@popperjs/core": "2.11.8",
177+
"@stylistic/eslint-plugin": "4.2.0",
177178
"@types/archiver": "6.0.3",
178179
"@types/better-sqlite3": "7.6.12",
179180
"@types/bootstrap": "5.2.10",
@@ -219,7 +220,7 @@
219220
"bootstrap": "5.3.3",
220221
"copy-webpack-plugin": "13.0.0",
221222
"cross-env": "7.0.3",
222-
"css-loader": "7.1.2",
223+
"css-loader": "7.1.2",
223224
"electron": "35.1.2",
224225
"eslint": "9.23.0",
225226
"esm": "3.2.25",
@@ -258,7 +259,6 @@
258259
"webpack-dev-middleware": "7.4.2"
259260
},
260261
"optionalDependencies": {
261-
"appdmg": "0.6.6",
262-
"dprint": "0.49.1"
262+
"appdmg": "0.6.6"
263263
}
264264
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"esModuleInterop": true,
1515
"verbatimModuleSyntax": true
1616
},
17-
"include": ["./src/**/*.js", "./src/**/*.ts", "./*.ts", "./spec/**/*.ts"],
17+
"include": ["./src/**/*.js", "./src/**/*.ts", "./*.ts", "./*.js", "./spec/**/*.ts"],
1818
"exclude": ["./node_modules/**/*", "./spec-es6/**/*.ts"],
1919
"files": ["src/types.d.ts", "src/public/app/types.d.ts"]
2020
}

0 commit comments

Comments
 (0)