mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-27 01:51:34 +08:00 
			
		
		
		
	Merge pull request #1575 from TriliumNext/chore_eslint-formatting
chore: use eslint for formatting and replace dprint
This commit is contained in:
		
						commit
						56eda374e0
					
				
							
								
								
									
										44
									
								
								.dprint.json
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								.dprint.json
									
									
									
									
									
								
							| @ -1,44 +0,0 @@ | ||||
| { | ||||
|   "typescript": { | ||||
|     "indentWidth": 4, | ||||
|     "quoteStyle": "preferDouble", | ||||
|     "semiColons": "prefer", | ||||
|     "quoteProps": "asNeeded", | ||||
|     "newLineKind": "lf", | ||||
|     "lineWidth": 200, | ||||
|     "trailingCommas": "never", | ||||
|     "arrayPattern.spaceAround": true, | ||||
|     "arrayExpression.spaceAround": true | ||||
|   }, | ||||
|   "json": { | ||||
|   }, | ||||
|   "markdown": { | ||||
|   }, | ||||
|   "dockerfile": { | ||||
|   }, | ||||
|   "malva": { | ||||
|   }, | ||||
|   "markup": { | ||||
|   }, | ||||
|   "yaml": { | ||||
|   }, | ||||
|   "excludes": [ | ||||
|     "**/node_modules", | ||||
|     "**/*-lock.json", | ||||
|     "*.html", | ||||
|     "*.md", | ||||
|     "*.yml", | ||||
|     "libraries/*", | ||||
|     "docs/*", | ||||
|     "src/public/app/doc_notes" | ||||
|   ], | ||||
|   "plugins": [ | ||||
|     "https://plugins.dprint.dev/typescript-0.94.0.wasm", | ||||
|     "https://plugins.dprint.dev/json-0.20.0.wasm", | ||||
|     "https://plugins.dprint.dev/markdown-0.18.0.wasm", | ||||
|     "https://plugins.dprint.dev/dockerfile-0.3.2.wasm", | ||||
|     "https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm", | ||||
|     "https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm", | ||||
|     "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										3
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
								
							| @ -4,6 +4,7 @@ | ||||
|     "editorconfig.editorconfig", | ||||
|     "vitest.explorer", | ||||
|     "ms-playwright.playwright", | ||||
|     "tobermory.es6-string-html" | ||||
|     "tobermory.es6-string-html", | ||||
|     "dbaeumer.vscode-eslint" | ||||
|   ] | ||||
| } | ||||
|  | ||||
| @ -24,8 +24,8 @@ export default tseslint.config( | ||||
|             "@typescript-eslint/no-unused-vars": [ | ||||
|                 "error", | ||||
|                 { | ||||
|                     "argsIgnorePattern": "^_", | ||||
|                     "varsIgnorePattern": "^_", | ||||
|                     argsIgnorePattern: "^_", | ||||
|                     varsIgnorePattern: "^_" | ||||
|                 } | ||||
|             ] | ||||
|         } | ||||
| @ -35,6 +35,7 @@ export default tseslint.config( | ||||
|             "build/*", | ||||
|             "dist/*", | ||||
|             "docs/*", | ||||
|             "demo/*", | ||||
|             "libraries/*", | ||||
|             "src/public/app-dist/*", | ||||
|             "src/public/app/doc_notes/*" | ||||
|  | ||||
							
								
								
									
										48
									
								
								eslint.format.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								eslint.format.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| 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/*", | ||||
|             "libraries/*", | ||||
|             // 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/*" | ||||
|         ] | ||||
|     } | ||||
| ]; | ||||
							
								
								
									
										176
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										176
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -117,6 +117,7 @@ | ||||
|         "@mind-elixir/node-menu": "1.0.5", | ||||
|         "@playwright/test": "1.51.1", | ||||
|         "@popperjs/core": "2.11.8", | ||||
|         "@stylistic/eslint-plugin": "4.2.0", | ||||
|         "@types/archiver": "6.0.3", | ||||
|         "@types/better-sqlite3": "7.6.12", | ||||
|         "@types/bootstrap": "5.2.10", | ||||
| @ -201,8 +202,7 @@ | ||||
|         "webpack-dev-middleware": "7.4.2" | ||||
|       }, | ||||
|       "optionalDependencies": { | ||||
|         "appdmg": "0.6.6", | ||||
|         "dprint": "0.49.1" | ||||
|         "appdmg": "0.6.6" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@ampproject/remapping": { | ||||
| @ -574,123 +574,6 @@ | ||||
|         "node": ">=14.17.0" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@dprint/darwin-arm64": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/darwin-arm64/-/darwin-arm64-0.49.1.tgz", | ||||
|       "integrity": "sha512-ib6KcJWo/M5RJWXOQKhP664FG1hAvG7nrbkh+j8n+oXdzmbyDdXTP+zW+aM3/sIQUkGaZky1xy1j2VeScMEEHQ==", | ||||
|       "cpu": [ | ||||
|         "arm64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "darwin" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/darwin-x64": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/darwin-x64/-/darwin-x64-0.49.1.tgz", | ||||
|       "integrity": "sha512-vIVgnYxV7YYa1d6Uyz707RbgB9rwefGPam+rzaueFNPQjdOxPOTQDuMEJDS+Z3BlI00MfeoupIfIUGsXoM4dpQ==", | ||||
|       "cpu": [ | ||||
|         "x64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "darwin" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/linux-arm64-glibc": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-glibc/-/linux-arm64-glibc-0.49.1.tgz", | ||||
|       "integrity": "sha512-ZeIh6qMPWLBBifDtU0XadpK36b4WoaTqCOt0rWKfoTjq1RAt78EgqETWp43Dbr6et/HvTgYdoWF0ZNEu2FJFFA==", | ||||
|       "cpu": [ | ||||
|         "arm64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "linux" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/linux-arm64-musl": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-musl/-/linux-arm64-musl-0.49.1.tgz", | ||||
|       "integrity": "sha512-/nuRyx+TykN6MqhlSCRs/t3o1XXlikiwTc9emWdzMeLGllYvJrcht9gRJ1/q1SqwCFhzgnD9H7roxxfji1tc+Q==", | ||||
|       "cpu": [ | ||||
|         "arm64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "linux" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/linux-riscv64-glibc": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/linux-riscv64-glibc/-/linux-riscv64-glibc-0.49.1.tgz", | ||||
|       "integrity": "sha512-RHBqrnvGO+xW4Oh0QuToBqWtkXMcfjqa1TqbBFF03yopFzZA2oRKX83PhjTWgd/IglaOns0BgmaLJy/JBSxOfQ==", | ||||
|       "cpu": [ | ||||
|         "riscv64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "linux" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/linux-x64-glibc": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/linux-x64-glibc/-/linux-x64-glibc-0.49.1.tgz", | ||||
|       "integrity": "sha512-MjFE894mIQXOKBencuakKyzAI4KcDe/p0Y9lRp9YSw/FneR4QWH9VBH90h8fRxcIlWMArjFFJJAtsBnn5qgxeg==", | ||||
|       "cpu": [ | ||||
|         "x64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "linux" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/linux-x64-musl": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/linux-x64-musl/-/linux-x64-musl-0.49.1.tgz", | ||||
|       "integrity": "sha512-CvGBWOksHgrL1uzYqtPFvZz0+E82BzgoCIEHJeuYaveEn37qWZS5jqoCm/vz6BfoivE1dVuyyOT78Begj9KxkQ==", | ||||
|       "cpu": [ | ||||
|         "x64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "linux" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/win32-arm64": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/win32-arm64/-/win32-arm64-0.49.1.tgz", | ||||
|       "integrity": "sha512-gQa4s82lMcXjfdxjWBQun6IJlXdPZZaIj2/2cqXWVEOYPKxAZ/JvGzt2pPG+i73h9KHjNLIV8M9ckqEH3oHufg==", | ||||
|       "cpu": [ | ||||
|         "arm64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "win32" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@dprint/win32-x64": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/@dprint/win32-x64/-/win32-x64-0.49.1.tgz", | ||||
|       "integrity": "sha512-nPU6+hoVze5JJlgET7woYWElBw0IUaB/9XKTaglknQuUUfsmD75D9pkgJTxdIxl9Bg/i5O7c9wb3Nj4XNiTIfw==", | ||||
|       "cpu": [ | ||||
|         "x64" | ||||
|       ], | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "os": [ | ||||
|         "win32" | ||||
|       ] | ||||
|     }, | ||||
|     "node_modules/@electron-forge/cli": { | ||||
|       "version": "7.8.0", | ||||
|       "resolved": "https://registry.npmjs.org/@electron-forge/cli/-/cli-7.8.0.tgz", | ||||
| @ -4554,6 +4437,39 @@ | ||||
|         "url": "https://github.com/sindresorhus/is?sponsor=1" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@stylistic/eslint-plugin": { | ||||
|       "version": "4.2.0", | ||||
|       "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-4.2.0.tgz", | ||||
|       "integrity": "sha512-8hXezgz7jexGHdo5WN6JBEIPHCSFyyU4vgbxevu4YLVS5vl+sxqAAGyXSzfNDyR6xMNSH5H1x67nsXcYMOHtZA==", | ||||
|       "dev": true, | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@typescript-eslint/utils": "^8.23.0", | ||||
|         "eslint-visitor-keys": "^4.2.0", | ||||
|         "espree": "^10.3.0", | ||||
|         "estraverse": "^5.3.0", | ||||
|         "picomatch": "^4.0.2" | ||||
|       }, | ||||
|       "engines": { | ||||
|         "node": "^18.18.0 || ^20.9.0 || >=21.1.0" | ||||
|       }, | ||||
|       "peerDependencies": { | ||||
|         "eslint": ">=9.0.0" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@stylistic/eslint-plugin/node_modules/picomatch": { | ||||
|       "version": "4.0.2", | ||||
|       "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", | ||||
|       "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", | ||||
|       "dev": true, | ||||
|       "license": "MIT", | ||||
|       "engines": { | ||||
|         "node": ">=12" | ||||
|       }, | ||||
|       "funding": { | ||||
|         "url": "https://github.com/sponsors/jonschlinkert" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@szmarczak/http-timer": { | ||||
|       "version": "4.0.6", | ||||
|       "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", | ||||
| @ -9507,28 +9423,6 @@ | ||||
|         "url": "https://github.com/fb55/domutils?sponsor=1" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/dprint": { | ||||
|       "version": "0.49.1", | ||||
|       "resolved": "https://registry.npmjs.org/dprint/-/dprint-0.49.1.tgz", | ||||
|       "integrity": "sha512-pO9XH79SyXybj2Vhc9ITZMEI8cJkdlQQRoD8oEfPH6Jjpp/7WX5kIgECVd3DBOjjAdCSiW6R47v3gJBx/qZVkw==", | ||||
|       "hasInstallScript": true, | ||||
|       "license": "MIT", | ||||
|       "optional": true, | ||||
|       "bin": { | ||||
|         "dprint": "bin.js" | ||||
|       }, | ||||
|       "optionalDependencies": { | ||||
|         "@dprint/darwin-arm64": "0.49.1", | ||||
|         "@dprint/darwin-x64": "0.49.1", | ||||
|         "@dprint/linux-arm64-glibc": "0.49.1", | ||||
|         "@dprint/linux-arm64-musl": "0.49.1", | ||||
|         "@dprint/linux-riscv64-glibc": "0.49.1", | ||||
|         "@dprint/linux-x64-glibc": "0.49.1", | ||||
|         "@dprint/linux-x64-musl": "0.49.1", | ||||
|         "@dprint/win32-arm64": "0.49.1", | ||||
|         "@dprint/win32-x64": "0.49.1" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/draggabilly": { | ||||
|       "version": "3.0.0", | ||||
|       "resolved": "https://registry.npmjs.org/draggabilly/-/draggabilly-3.0.0.tgz", | ||||
|  | ||||
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							| @ -59,8 +59,8 @@ | ||||
|     "test:integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 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:format-check": "dprint check", | ||||
|     "dev:format-fix": "dprint fmt", | ||||
|     "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:update-build-info": "tsx bin/update-build-info.ts", | ||||
| @ -174,6 +174,7 @@ | ||||
|     "@mind-elixir/node-menu": "1.0.5", | ||||
|     "@playwright/test": "1.51.1", | ||||
|     "@popperjs/core": "2.11.8", | ||||
|     "@stylistic/eslint-plugin": "4.2.0", | ||||
|     "@types/archiver": "6.0.3", | ||||
|     "@types/better-sqlite3": "7.6.12", | ||||
|     "@types/bootstrap": "5.2.10", | ||||
| @ -219,7 +220,7 @@ | ||||
|     "bootstrap": "5.3.3", | ||||
|     "copy-webpack-plugin": "13.0.0", | ||||
|     "cross-env": "7.0.3", | ||||
|     "css-loader": "7.1.2",     | ||||
|     "css-loader": "7.1.2", | ||||
|     "electron": "35.1.2", | ||||
|     "eslint": "9.23.0", | ||||
|     "esm": "3.2.25", | ||||
| @ -258,7 +259,6 @@ | ||||
|     "webpack-dev-middleware": "7.4.2" | ||||
|   }, | ||||
|   "optionalDependencies": { | ||||
|     "appdmg": "0.6.6", | ||||
|     "dprint": "0.49.1" | ||||
|     "appdmg": "0.6.6" | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -14,7 +14,7 @@ | ||||
|     "esModuleInterop": true, | ||||
|     "verbatimModuleSyntax": true | ||||
|   }, | ||||
|   "include": ["./src/**/*.js", "./src/**/*.ts", "./*.ts", "./spec/**/*.ts"], | ||||
|   "include": ["./src/**/*.js", "./src/**/*.ts", "./*.ts", "./*.js", "./spec/**/*.ts"], | ||||
|   "exclude": ["./node_modules/**/*", "./spec-es6/**/*.ts"], | ||||
|   "files": ["src/types.d.ts", "src/public/app/types.d.ts"] | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran