Skip to content

Build your personal knowledge base with Trilium Notes

chore(eslint): integrate formatter config

Elian Doranacd60007ac37
diff --git a/_regroup/eslint.config.js b/_regroup/eslint.config.js
index 7c906beb2b..2162c7eb70 100644
--- a/_regroup/eslint.config.js
+++ b/_regroup/eslint.config.js
@@ -1,22 +1,7 @@
-import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import simpleImportSort from "eslint-plugin-simple-import-sort";
export default tseslint.config(
- eslint.configs.recommended,
- tseslint.configs.recommended,
- // consider using rules below, once we have a full TS codebase and can be more strict
- // tseslint.configs.strictTypeChecked,
- // tseslint.configs.stylisticTypeChecked,
- // tseslint.configs.recommendedTypeChecked,
- {
- languageOptions: {
- parserOptions: {
- projectService: true,
- tsconfigRootDir: import.meta.dirname
- }
- }
- },
{
plugins: {
"simple-import-sort": simpleImportSort
@@ -37,15 +22,5 @@ export default tseslint.config(
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
}
- },
- {
- ignores: [
- "build/*",
- "dist/*",
- "docs/*",
- "demo/*",
- "src/public/app-dist/*",
- "src/public/app/doc_notes/*"
- ]
}
);
diff --git a/_regroup/eslint.format.config.js b/_regroup/eslint.format.config.js
deleted file mode 100644
index 9dbfd78b2e..0000000000
--- a/_regroup/eslint.format.config.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import stylistic from "@stylistic/eslint-plugin";
-import tsParser from "@typescript-eslint/parser";
-
-// eslint config just for formatting rules
-// potentially to be merged with the linting rules into one single config,
-// once we have fixed the majority of lint errors
-
-// Go to https://eslint.style/rules/default/${rule_without_prefix} to check the rule details
-export const stylisticRules = {
- "@stylistic/indent": [ "error", 4 ],
- "@stylistic/quotes": [ "error", "double", { avoidEscape: true, allowTemplateLiterals: "always" } ],
- "@stylistic/semi": [ "error", "always" ],
- "@stylistic/quote-props": [ "error", "consistent-as-needed" ],
- "@stylistic/max-len": [ "error", { code: 100 } ],
- "@stylistic/comma-dangle": [ "error", "never" ],
- "@stylistic/linebreak-style": [ "error", "unix" ],
- "@stylistic/array-bracket-spacing": [ "error", "always" ],
- "@stylistic/object-curly-spacing": [ "error", "always" ],
- "@stylistic/padded-blocks": [ "error", { classes: "always" } ]
-};
-
-export default [
- {
- files: [ "**/*.{js,ts,mjs,cjs}" ],
- languageOptions: {
- parser: tsParser
- },
- plugins: {
- "@stylistic": stylistic
- },
- rules: {
- ...stylisticRules
- }
- },
- {
- ignores: [
- "build/*",
- "dist/*",
- "docs/*",
- "demo/*",
- // TriliumNextTODO: check if we want to format packages here as well - for now skipping it
- "packages/*",
- "src/public/app-dist/*",
- "src/public/app/doc_notes/*"
- ]
- }
-];
diff --git a/_regroup/package.json b/_regroup/package.json
index d42e107f46..708c5bcc01 100644
--- a/_regroup/package.json
+++ b/_regroup/package.json
@@ -26,11 +26,7 @@
"test:integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",
"test:integration-mem-db": "cross-env nodemon src/main.ts",
"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",
- "dev:watch-dist": "tsx ./bin/watch-dist.ts",
- "dev:format-check": "eslint -c eslint.format.config.js .",
- "dev:format-fix": "eslint -c eslint.format.config.js . --fix",
- "dev:linter-check": "eslint .",
- "dev:linter-fix": "eslint . --fix",
+ "dev:watch-dist": "tsx ./bin/watch-dist.ts",
"chore:generate-document": "cross-env nodemon ./bin/generate_document.ts 1000",
"chore:generate-openapi": "tsx bin/generate-openapi.js"
},
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 3c6b57d2da..082bcad223 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -8,8 +8,26 @@ export default defineConfig(
globalIgnores([
".cache",
"tmp",
- "**/dist"
+ "**/dist",
+ "**/out-tsc",
+ "apps/edit-docs/demo/*",
+ "docs/*",
+ "apps/web-clipper/lib/*",
+ // TODO: check if we want to format packages here as well - for now skipping it
+ "packages/*",
]),
eslint.configs.recommended,
tseslint.configs.recommended,
+ // consider using rules below, once we have a full TS codebase and can be more strict
+ // tseslint.configs.strictTypeChecked,
+ // tseslint.configs.stylisticTypeChecked,
+ // tseslint.configs.recommendedTypeChecked,
+ {
+ languageOptions: {
+ parserOptions: {
+ projectService: true,
+ tsconfigRootDir: import.meta.dirname
+ }
+ }
+ }
);
diff --git a/eslint.format.config.mjs b/eslint.format.config.mjs
new file mode 100644
index 0000000000..b9591c3d37
--- /dev/null
+++ b/eslint.format.config.mjs
@@ -0,0 +1,51 @@
+// @ts-check
+
+import { defineConfig, globalIgnores } from 'eslint/config';
+import tsParser from "@typescript-eslint/parser";
+import stylistic from "@stylistic/eslint-plugin";
+
+// eslint config just for formatting rules
+// potentially to be merged with the linting rules into one single config,
+// once we have fixed the majority of lint errors
+
+// Go to https://eslint.style/rules/default/${rule_without_prefix} to check the rule details
+export const stylisticRules = {
+ "@stylistic/indent": ["error", 4],
+ "@stylistic/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: "always" }],
+ "@stylistic/semi": ["error", "always"],
+ "@stylistic/quote-props": ["error", "consistent-as-needed"],
+ "@stylistic/max-len": ["error", { code: 100 }],
+ "@stylistic/comma-dangle": ["error", "never"],
+ "@stylistic/linebreak-style": ["error", "unix"],
+ "@stylistic/array-bracket-spacing": ["error", "always"],
+ "@stylistic/object-curly-spacing": ["error", "always"],
+ "@stylistic/padded-blocks": ["error", { classes: "always" }]
+};
+
+export default defineConfig(
+ globalIgnores([
+ ".cache",
+ "tmp",
+ "**/dist",
+ "**/out-tsc",
+ "apps/edit-docs/demo/*",
+ "docs/*",
+ "apps/web-clipper/lib/*"
+ ]),
+
+ {
+ files: ["**/*.{js,ts,mjs,cjs}"],
+
+ languageOptions: {
+ parser: tsParser
+ },
+
+ plugins: {
+ "@stylistic": stylistic
+ },
+
+ rules: {
+ ...stylisticRules
+ }
+ }
+);
\ No newline at end of file
diff --git a/package.json b/package.json
index ac54e7bc29..35068b908e 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,10 @@
"test:parallel": "pnpm --filter=!server --filter=!ckeditor5-mermaid --filter=!ckeditor5-math --parallel test",
"test:sequential": "pnpm --filter=server --filter=ckeditor5-mermaid --filter=ckeditor5-math --sequential test",
"typecheck": "tsc --build",
+ "dev:format-check": "eslint -c eslint.format.config.mjs .",
+ "dev:format-fix": "eslint -c eslint.format.config.mjs . --fix",
+ "dev:linter-check": "cross-env NODE_OPTIONS=--max_old_space_size=4096 eslint .",
+ "dev:linter-fix": "cross-env NODE_OPTIONS=--max_old_space_size=4096 eslint . --fix",
"postinstall": "tsx scripts/electron-rebuild.mts"
},
"private": true,