فهرست منبع

Replace ESLint with Biome (#4889)

Alec Rust 1 سال پیش
والد
کامیت
82db254600

+ 0 - 11
.eslintignore

@@ -1,11 +0,0 @@
-# Minified files
-*.min.js
-
-# Vendor/packages
-**/node_modules/
-**/vendor/
-
-# VitePress
-**/.vitepress/dist/
-!docs/.vitepress/
-docs/.vitepress/cache/

+ 0 - 41
.eslintrc.cjs

@@ -1,41 +0,0 @@
-module.exports = {
-	root: true,
-	parserOptions: {
-		sourceType: 'module',
-		ecmaVersion: 'latest',
-	},
-	extends: [
-		'eslint:recommended',
-		'plugin:editorconfig/noconflict',
-		'plugin:import/recommended',
-		'prettier',
-	],
-	plugins: ['editorconfig', 'import'],
-	ignorePatterns: ['*.cjs'],
-	env: {
-		browser: true,
-		es2021: true,
-	},
-	globals: {
-		Alpine: 'readonly',
-	},
-	rules: {
-		'no-unused-vars': [
-			'error',
-			{
-				argsIgnorePattern: '^_',
-				varsIgnorePattern: '^_',
-				caughtErrorsIgnorePattern: '^_',
-			},
-		],
-		'import/order': [
-			'error',
-			{
-				groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
-			},
-		],
-		'no-console': 'error',
-		'prefer-const': 'error',
-		'import/no-unresolved': 'off',
-	},
-};

+ 6 - 14
.github/workflows/lint.yml

@@ -39,9 +39,6 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
-        with:
-          repository: ${{ github.event.pull_request.head.repo.full_name }}
-          ref: ${{ github.event.pull_request.head.ref }}
 
       - name: Setup Node
         uses: actions/setup-node@v4
@@ -54,23 +51,18 @@ jobs:
       - name: Check formatting
         run: npx prettier --check .
 
-  eslint:
-    name: ESLint
+  biome:
+    name: Biome
     runs-on: ubuntu-latest
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
 
-      - name: Setup Node
-        uses: actions/setup-node@v4
-        with:
-          node-version: "lts/*"
-
-      - name: Install Node packages
-        run: npm ci --ignore-scripts
+      - name: Setup Biome
+        uses: biomejs/setup-biome@v2
 
-      - name: Run ESLint
-        run: npx eslint .
+      - name: Run Biome lint
+        run: biome lint .
 
   stylelint:
     name: Stylelint

+ 0 - 3
.gitignore

@@ -48,6 +48,3 @@ web/src/vendor/
 # Node
 **/node_modules/
 npm-debug.log
-
-# optional eslint cache
-.eslintcache

+ 3 - 3
.lintstagedrc.cjs

@@ -3,8 +3,8 @@ module.exports = {
 	'*.md': 'markdownlint-cli2 --fix',
 	// Run Stylelint on CSS files
 	'*.css': 'stylelint --fix --allow-empty-input',
-	// Run ESLint on TS, TSX, JS, JSX files
-	'*.{ts,js}?(x)': 'eslint --fix',
-	// Run Prettier everywhere
+	// Run Biome on TS, TSX, JS, JSX files
+	'*.{ts,js}?(x)': 'npx @biomejs/biome lint --write --no-errors-on-unmatched',
+	// Run Prettier where supported
 	'*': 'prettier --write --ignore-unknown',
 };

+ 1 - 1
.vscode/extensions.json

@@ -3,7 +3,7 @@
 		"editorconfig.editorconfig",
 		"esbenp.prettier-vscode",
 		"DavidAnson.vscode-markdownlint",
-		"dbaeumer.vscode-eslint",
+		"biomejs.biome",
 		"stylelint.vscode-stylelint",
 		"timonwong.shellcheck",
 		"mrmlnc.vscode-apache",

+ 1 - 1
.vscode/settings.json

@@ -7,7 +7,7 @@
 	"explorer.fileNesting.patterns": {
 		"*.css": "${capture}.css.map",
 		"*.js": "${capture}.js.map",
-		"package.json": ".editorconfig, .eslint*, .lintstaged*, .markdownlint-cli2*, .prettier*, .stylelint*, jsconfig.json, package-lock.json, renovate.json",
+		"package.json": ".editorconfig, .biome*, .lintstaged*, .markdownlint-cli2*, .prettier*, .stylelint*, jsconfig.json, package-lock.json, renovate.json",
 		"readme*": "changelog*, contributing*, license*, security*"
 	}
 }

+ 59 - 0
biome.json

@@ -0,0 +1,59 @@
+{
+	"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
+	"vcs": {
+		"enabled": false,
+		"clientKind": "git",
+		"useIgnoreFile": false
+	},
+	"files": {
+		"ignoreUnknown": false,
+		"ignore": [
+			"**/*.bats",
+			"./test/test_helper/*",
+			"**/*.min.css",
+			"**/*.min.js",
+			"**/vendor/**",
+			"**/node_modules/**",
+			"**/.vitepress/dist/",
+			"**/.vitepress/cache/",
+			"./docs/.vitepress/dist/",
+			"./docs/.vitepress/cache/"
+		]
+	},
+	"formatter": {
+		"enabled": false,
+		"useEditorconfig": true
+	},
+	"organizeImports": {
+		"enabled": true
+	},
+	"linter": {
+		"enabled": true,
+		"rules": {
+			"recommended": true,
+			"a11y": {
+				"useGenericFontNames": "off"
+			},
+			"style": {
+				"noParameterAssign": "off"
+			},
+			"complexity": {
+				"noForEach": "off"
+			},
+			"correctness": {
+				"noUnknownMediaFeatureName": "off"
+			},
+			"suspicious": {
+				"noEmptyBlock": "off",
+				"noShorthandPropertyOverrides": "off",
+				"noDoubleEquals": "off"
+			}
+		}
+	},
+	"javascript": {
+		"formatter": {
+			"quoteStyle": "single"
+		},
+		"globals": ["Alpine"]
+	}
+}

+ 0 - 3
build.js

@@ -1,6 +1,3 @@
-/* eslint-env node */
-/* eslint-disable no-console */
-
 // Build JS and CSS using esbuild and Lightning CSS
 import { promises as fs } from 'node:fs';
 import path from 'node:path';

+ 1 - 1
docs/.vitepress/theme/components/InstallBuilder.vue

@@ -113,7 +113,7 @@ watchEffect(() => {
 	};
 	for (const [key, { enabled, value }] of Object.entries(selectedOptions.value)) {
 		const opt = options.find((o) => o.flag === key);
-		if (opt.flag == "force" && enabled) {
+		if (opt.flag === "force" && enabled) {
 			cmd += " --force";
 		} else if (!opt.type || opt.type === "checkbox") {
 			if (enabled !== (opt.default === "yes")) {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 251 - 883
package-lock.json


+ 2 - 5
package.json

@@ -12,7 +12,7 @@
 		"docs:serve": "vitepress serve docs",
 		"docs:test": "vitest run --config docs/.vitepress/vitest.config.js",
 		"build": "node build.js",
-		"lint": "prettier --cache --check . && eslint --cache . && stylelint web/css/src/**/*.css && markdownlint-cli2 *.md docs/**/*.md",
+		"lint": "prettier --cache --check . && npx @biomejs/biome lint . && stylelint web/css/src/**/*.css && markdownlint-cli2 *.md docs/**/*.md",
 		"lint-staged": "lint-staged",
 		"format": "prettier --cache --write .",
 		"preinstall": "npx only-allow npm",
@@ -32,15 +32,12 @@
 		"xterm-addon-webgl": "^0.16.0"
 	},
 	"devDependencies": {
+		"@biomejs/biome": "1.9.4",
 		"@prettier/plugin-php": "^0.22.4",
 		"@testing-library/vue": "^8.1.0",
 		"@vitejs/plugin-vue": "^5.2.1",
 		"browserslist": "^4.24.4",
 		"esbuild": "^0.25.0",
-		"eslint": "^8.57.1",
-		"eslint-config-prettier": "^9.1.0",
-		"eslint-plugin-editorconfig": "^4.0.3",
-		"eslint-plugin-import": "^2.31.0",
 		"husky": "^9.1.7",
 		"jsdom": "^25.0.1",
 		"lightningcss": "^1.29.1",

+ 2 - 1
renovate.json

@@ -7,7 +7,8 @@
 		"group:allNonMajor",
 		"group:linters",
 		":automergeLinters",
-		":disableDependencyDashboard"
+		":disableDependencyDashboard",
+		"customManagers:biomeVersions"
 	],
 	"ignorePaths": ["**/node_modules/**", "install/deb/filemanager/filegator/composer.json"],
 	"rangeStrategy": "bump",

+ 0 - 9
src/deb/web-terminal/.eslintrc.cjs

@@ -1,9 +0,0 @@
-module.exports = {
-	env: {
-		browser: false,
-		node: true,
-	},
-	rules: {
-		'no-console': 'off',
-	},
-};

+ 1 - 1
web/js/src/ftpAccounts.js

@@ -92,7 +92,7 @@ function handleDeleteAccountClick() {
 
 			updateUserNumbers();
 
-			if (document.querySelectorAll('.js-active-ftp-accounts .js-ftp-account-nrm').length == 0) {
+			if (document.querySelectorAll('.js-active-ftp-accounts .js-ftp-account-nrm').length === 0) {
 				document.querySelector('.js-add-ftp-account').style.display = 'none';
 				document.querySelector('input[name="v_ftp"]').checked = false;
 			}

+ 2 - 2
web/js/src/shortcuts.js

@@ -97,14 +97,14 @@ export default function handleShortcuts() {
 		 */
 		unregister(combination) {
 			const shortcut = this.registeredShortcuts.find(
-				(shortcut) => JSON.stringify(shortcut.combination) === JSON.stringify(combination),
+				(shortcut) => JSON.stringify(shortcut.combination) == JSON.stringify(combination),
 			);
 			if (!shortcut) {
 				return;
 			}
 
 			this.registeredShortcuts = this.registeredShortcuts.filter(
-				(shortcut) => JSON.stringify(shortcut.combination) !== JSON.stringify(combination),
+				(shortcut) => JSON.stringify(shortcut.combination) != JSON.stringify(combination),
 			);
 			shortcut.target.removeEventListener(shortcut.event, shortcut.callback, false);
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است