Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add biome #1281

Merged
merged 28 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fd7a65a
feat: biome
ErKeLost May 3, 2024
712e975
chore: test biome
ErKeLost May 3, 2024
61bb755
chore: update code
ErKeLost May 3, 2024
f8d2dcb
chore: update code
ErKeLost May 3, 2024
7ea1b8b
chore: update changeset
ErKeLost May 3, 2024
01240e1
chore: update biome rules
ErKeLost May 4, 2024
7677feb
chore: enable biome lint
ErKeLost May 4, 2024
0d87df6
chore: remove eslint and prettier
ErKeLost May 4, 2024
df4a308
chore: remove eslint and prettier
ErKeLost May 4, 2024
36252ae
Merge branch 'main' into feat/biome_2
ErKeLost May 4, 2024
eec7d09
chore: test lint-staged
ErKeLost May 4, 2024
11d28dd
chore: test lint-staged
ErKeLost May 4, 2024
05daacb
Merge branch 'feat/biome_2' of github.com:ErKeLost/farm into feat/bio…
ErKeLost May 4, 2024
5bc4606
chore: test lint-staged
ErKeLost May 4, 2024
1e6c7b4
chore: test lint-staged
ErKeLost May 4, 2024
f079d5c
chore: test lint-staged
ErKeLost May 4, 2024
50968e0
chore: test lint-staged
ErKeLost May 4, 2024
9127dfd
chore: test lint-staged
ErKeLost May 4, 2024
8fcbb28
chore: update test lint-staged
ErKeLost May 4, 2024
08d566d
chore: update test lint-staged
ErKeLost May 4, 2024
633e54c
chore: update test lint-staged
ErKeLost May 4, 2024
144960c
chore: update test lint-staged
ErKeLost May 4, 2024
d7ee852
chore: update husky
ErKeLost May 4, 2024
50eadbd
chore: update husky
ErKeLost May 4, 2024
2ea1fd3
chore: update husky
ErKeLost May 4, 2024
31ab041
chore: update husky
ErKeLost May 4, 2024
2ffe5e9
chore: update husky
ErKeLost May 4, 2024
df62f7a
chore: update husky
ErKeLost May 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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