Skip to content

Commit

Permalink
feat: add biome (#1281)
Browse files Browse the repository at this point in the history
* feat: biome

* chore: test biome

* chore: update code

* chore: update code

* chore: update changeset

* chore: update biome rules

* chore: enable biome lint

* chore: remove eslint and prettier

* chore: remove eslint and prettier

* chore: test lint-staged

* chore: test lint-staged

* chore: test lint-staged

* chore: test lint-staged

* chore: test lint-staged

* chore: test lint-staged

* chore: test lint-staged

* chore: update test lint-staged

* chore: update test lint-staged

* chore: update test lint-staged

* chore: update test lint-staged

* chore: update husky

* chore: update husky

* chore: update husky

* chore: update husky

* chore: update husky

* chore: update husky
  • Loading branch information
ErKeLost committed May 5, 2024
1 parent 28e1a37 commit e5868af
Show file tree
Hide file tree
Showing 157 changed files with 1,156 additions and 1,794 deletions.
2 changes: 2 additions & 0 deletions .changeset/sweet-stingrays-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc.base.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: cargo fmt
- name: Run cargo clippy
run: cargo clippy
eslint:
lint:
name: TS Code Lint
runs-on: ubuntu-latest
steps:
Expand All @@ -32,5 +32,5 @@ jobs:
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Run eslint
run: npx eslint packages
- name: Run lint
run: npx biome check --no-errors-on-unmatched --files-ignore-unknown=true
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
12 changes: 7 additions & 5 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ function readPackage(pkg, context) {
// Replace [email protected] with [email protected]
pkg.peerDependencies = {
vue: pkg.version
}
context.log(`${pkg.name}@${pkg.version} => vue@${pkg.version} in peerDependencies`)
};
context.log(
`${pkg.name}@${pkg.version} => vue@${pkg.version} in peerDependencies`
);
}
return pkg

return pkg;
}

module.exports = {
hooks: {
readPackage
}
}
};
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

138 changes: 138 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.2/schema.json",
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignore": [
"crates/**",
"*.vue",
"examples/**",
"tsconfig.base.json",
"tsconfig.json",
"cspell.json",
"e2e/**",
"*.e2e.ts",
"*.d.ts",
"packages/runtime/**",
"packages/runtime-plugin-import-meta/**",
"packages/create-farm/templates/**",
"packages/create-farm-plugin/templates/**",
"rust-plugins/**",
"js-plugins/vue",
"js-plugins/less",
"js-plugins/sass"
],
"ignoreUnknown": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto"
},
"organizeImports": {
"enabled": true,
"include": ["./**/*.js", "./**/*.ts", "./**/*.mjs"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noBannedTypes": "error",
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessTypeConstraint": "error",
"noWith": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "warn",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "warn",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"style": {
"noInferrableTypes": "error",
"noNamespace": "error",
"noNonNullAssertion": "warn",
"useAsConstAssertion": "error"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "off",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "off",
"noExplicitAny": "off",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noMisleadingInstantiator": "error",
"noPrototypeBuiltins": "warn",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useNamespaceKeyword": "error",
"useValidTypeof": "error"
}
},
"ignore": [
"**/binding/**",
"**/templates/**",
"**/dist/**",
"**/node_modules/**",
"**/*.config.js",
"**/*.config.ts"
]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "single",
"quoteProperties": "asNeeded",
"trailingComma": "none",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
}
}
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
}
};
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@
"icns",
"idents",
"IHDR",
"JIDA",
"importee",
"indicatif",
"Instantiator",
"jfif",
"JIDA",
"jridgewell",
"jsnext",
"kolorist",
Expand All @@ -92,6 +93,7 @@
"nanospinner",
"napi",
"NAPI",
"Nonoctal",
"normpath",
"npmlog",
"onwarn",
Expand Down
8 changes: 0 additions & 8 deletions e2e/.eslintrc.json

This file was deleted.

22 changes: 11 additions & 11 deletions js-plugins/dts/farm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { builtinModules } from "module";
import { builtinModules } from 'module';

/**
* @type {import('@farmfe/core').UserConfig}
*/
export default {
compilation: {
input: {
index: "./src/index.ts",
index: './src/index.ts'
},
output: {
path: "build",
entryFilename: "[entryName].cjs",
targetEnv: "node",
format: "cjs",
path: 'build',
entryFilename: '[entryName].cjs',
targetEnv: 'node',
format: 'cjs'
},
partialBundling: {
enforceResources: [
{
name: "index.js",
test: [".+"],
},
],
name: 'index.js',
test: ['.+']
}
]
},
minify: false,
sourcemap: false,
persistentCache: false,
presetEnv: false,
presetEnv: false
}
};
7 changes: 2 additions & 5 deletions js-plugins/dts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,5 @@
"@farmfe/core": "workspace:*",
"@types/fs-extra": "^11.0.1"
},
"files": [
"dist",
"build"
]
}
"files": ["dist", "build"]
}
16 changes: 8 additions & 8 deletions js-plugins/dts/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os from 'node:os';
import { relative, resolve } from 'node:path';
import type { UserConfig } from '@farmfe/core';
import { DefaultLogger } from './logger.js';
import chalk from 'chalk';
import glob from 'fast-glob';
import os from 'node:os';
import { relative, resolve } from 'node:path';
import { CompilerOptions, Project, SourceFile } from 'ts-morph';
import { DefaultLogger } from './logger.js';
import {
ensureAbsolute,
ensureArray,
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class Context {
noEmitOnError: false,
skipDiagnostics: true,
copyDtsFiles: false,
afterDiagnostic: () => {}
afterDiagnostic: () => ({})
};

const userOptions = mergeObjects(defaultOption, options);
Expand All @@ -58,7 +58,7 @@ export default class Context {
: this.config.output?.path;
const aliasesExclude = userOptions?.aliasesExclude ?? [];
const tsConfigPath = resolveAbsolutePath(userOptions.tsconfigPath, root);
libFolderPath = libFolderPath && ensureAbsolute(libFolderPath, root);
const folderPath = libFolderPath && ensureAbsolute(libFolderPath, root);
const compilerOptions = userOptions.compilerOptions ?? {};

const mergeCompilerOptions = {
Expand All @@ -75,7 +75,7 @@ export default class Context {
} as CompilerOptions),
tsConfigFilePath: tsConfigPath,
skipAddingFilesFromTsConfig: true,
libFolderPath
libFolderPath: folderPath
};
this.project = new Project(mergeCompilerOptions);
const tsConfigOptions = getTsConfig(
Expand Down Expand Up @@ -108,8 +108,8 @@ export default class Context {
(isRegExp(find)
? find.toString() === alias.toString()
: isRegExp(alias)
? find.match(alias)?.[0]
: find === alias)
? find.match(alias)?.[0]
: find === alias)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion js-plugins/dts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { JsPlugin } from '@farmfe/core';

import Context from './context.js';
import { tryToReadFileSync } from './utils.js';
import { pluginName } from './options.js';
import { tryToReadFileSync } from './utils.js';

import type { DtsPluginOptions } from './types.js';

Expand Down
2 changes: 1 addition & 1 deletion js-plugins/dts/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ts, Diagnostic } from 'ts-morph';
import type { Diagnostic, ts } from 'ts-morph';

export interface DtsPluginOptions {
/**
Expand Down

0 comments on commit e5868af

Please sign in to comment.