mirror of
https://github.com/zadam/trilium.git
synced 2025-12-11 09:54:23 +01:00
chore(eslint): integrate formatter config
This commit is contained in:
parent
dfb9ce990d
commit
acd60007ac
@ -1,22 +1,7 @@
|
|||||||
import eslint from "@eslint/js";
|
|
||||||
import tseslint from "typescript-eslint";
|
import tseslint from "typescript-eslint";
|
||||||
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
||||||
|
|
||||||
export default tseslint.config(
|
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: {
|
plugins: {
|
||||||
"simple-import-sort": simpleImportSort
|
"simple-import-sort": simpleImportSort
|
||||||
@ -37,15 +22,5 @@ export default tseslint.config(
|
|||||||
"simple-import-sort/imports": "error",
|
"simple-import-sort/imports": "error",
|
||||||
"simple-import-sort/exports": "error"
|
"simple-import-sort/exports": "error"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
ignores: [
|
|
||||||
"build/*",
|
|
||||||
"dist/*",
|
|
||||||
"docs/*",
|
|
||||||
"demo/*",
|
|
||||||
"src/public/app-dist/*",
|
|
||||||
"src/public/app/doc_notes/*"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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/*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
@ -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-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": "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",
|
"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: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",
|
|
||||||
"chore:generate-document": "cross-env nodemon ./bin/generate_document.ts 1000",
|
"chore:generate-document": "cross-env nodemon ./bin/generate_document.ts 1000",
|
||||||
"chore:generate-openapi": "tsx bin/generate-openapi.js"
|
"chore:generate-openapi": "tsx bin/generate-openapi.js"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,8 +8,26 @@ export default defineConfig(
|
|||||||
globalIgnores([
|
globalIgnores([
|
||||||
".cache",
|
".cache",
|
||||||
"tmp",
|
"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,
|
eslint.configs.recommended,
|
||||||
tseslint.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
51
eslint.format.config.mjs
Normal file
51
eslint.format.config.mjs
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
@ -34,6 +34,10 @@
|
|||||||
"test:parallel": "pnpm --filter=!server --filter=!ckeditor5-mermaid --filter=!ckeditor5-math --parallel test",
|
"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",
|
"test:sequential": "pnpm --filter=server --filter=ckeditor5-mermaid --filter=ckeditor5-math --sequential test",
|
||||||
"typecheck": "tsc --build",
|
"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"
|
"postinstall": "tsx scripts/electron-rebuild.mts"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user