Skip to content

Commit

Permalink
💚 Use biome
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Jan 9, 2025
1 parent b882934 commit 106aad3
Show file tree
Hide file tree
Showing 10 changed files with 995 additions and 135 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ repos:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
exclude_types:
- markdown
- repo: https://github.com/lunarmodules/luacheck
rev: v1.2.0
hooks:
Expand Down
113 changes: 113 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": { "ignoreUnknown": false, "ignore": [] },
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 120,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": { "noBannedTypes": "error", "noUselessThisAlias": "error", "useArrowFunction": "off" },
"correctness": { "noUnusedVariables": "warn", "useArrayLiterals": "off" },
"style": {
"noInferrableTypes": "error",
"noNamespace": "off",
"noNonNullAssertion": "off",
"useAsConstAssertion": "error",
"useBlockStatements": "off"
},
"suspicious": {
"noEmptyBlockStatements": "off",
"noEmptyInterface": "error",
"noExplicitAny": "off",
"noExtraNonNullAssertion": "error",
"noMisleadingInstantiator": "error",
"useNamespaceKeyword": "error"
}
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"overrides": [
{
"include": ["*.ts", "*.tsx"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": { "noArguments": "error", "noVar": "error", "useConst": "error" },
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off",
"useValidTypeof": "off"
}
}
}
},
{
"include": ["*.ts", "*.tsx"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": { "noArguments": "error", "noVar": "error", "useConst": "error" },
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off",
"useValidTypeof": "off"
}
}
}
}
]
}
16 changes: 0 additions & 16 deletions eslintrc.js

This file was deleted.

68 changes: 11 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,33 @@
"author": "Tony Fettes <[email protected]>",
"license": "MIT",
"main": "lib/index.js",
"keywords": [
"coc.nvim",
"rime"
],
"keywords": ["coc.nvim", "rime"],
"engines": {
"coc": "^0.0.80"
},
"scripts": {
"lint": "eslint src --ext ts",
"lint": "biome lint",
"clean": "rimraf lib",
"watch": "node esbuild.js --watch",
"prepack": "xmake -y && xmake install && pkg-prebuilds-copy --baseDir build/release --source rime.node --name=rime --strip --napi_version=7 && node esbuild.js",
"prepare": "npm-run-all clean prepack"
},
"prettier": {
"singleQuote": true,
"printWidth": 120,
"semi": true
},
"devDependencies": {
"@types/mkdirp": "^0.5.2",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"biome": "^0.3.3",
"coc.nvim": "^0.0.80",
"esbuild": "^0.20.2",
"eslint": "^7.14.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.1.4",
"mkdirp": "^0.5.1",
"npm-run-all": "^4.1.5",
"pkg-prebuilds": "^1.0.0",
"prettier": "^2.2.0",
"rimraf": "^5.0.5",
"typescript": "^4.1.2",
"vscode-languageserver-protocol": "^3.14.1",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.14.0",
"xmake-build-system": "2.9.7"
},
"activationEvents": [
"*"
],
"activationEvents": ["*"],
"contributes": {
"configuration": {
"type": "object",
Expand Down Expand Up @@ -74,10 +59,7 @@
"rime.traits.shared_data_dir": {
"oneOf": [
{
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
{
"type": "array",
Expand All @@ -97,10 +79,7 @@
"rime.traits.user_data_dir": {
"oneOf": [
{
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
{
"type": "array",
Expand All @@ -118,18 +97,12 @@
"description": "user data directory of rime. `null` will not use user data (just use shared data)"
},
"rime.traits.log_dir": {
"type": [
"string",
"null"
],
"type": ["string", "null"],
"default": "",
"description": "log directory of rime. By default, it will be `~/.config/coc/extensions/coc-rime-data`. `null` will disable logging"
},
"rime.traits.distribution_name": {
"type": [
"string",
"null"
],
"type": ["string", "null"],
"default": "Rime"
},
"rime.traits.distribution_code_name": {
Expand All @@ -141,21 +114,13 @@
"default": "0.1.3"
},
"rime.traits.app_name": {
"type": [
"string",
"null"
],
"type": ["string", "null"],
"default": "rime.coc-rime",
"description": "Pass a C-string constant in the format \"rime.x\" where 'x' is the name of your application. Add prefix \"rime.\" to ensure old log files are automatically cleaned."
},
"rime.traits.min_log_level": {
"type": "integer",
"enum": [
0,
1,
2,
3
],
"enum": [0, 1, 2, 3],
"default": 3,
"description": "Minimal level of logged messages. Value is passed to Glog library using FLAGS_minloglevel variable. 0 = INFO (default), 1 = WARNING, 2 = ERROR, 3 = FATAL"
},
Expand All @@ -164,18 +129,7 @@
"items": {
"type": "string"
},
"default": [
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
],
"default": ["", "", "", "", "", "", "", "", "", ""],
"description": "indices for IME"
},
"rime.ui.left": {
Expand Down
4 changes: 2 additions & 2 deletions src/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { resolve } from 'path';
import { default as build, Options } from 'pkg-prebuilds';
import { execSync } from 'child_process';

let options: Options = { name: 'rime', napi_versions: [7] };
const options: Options = { name: 'rime', napi_versions: [7] };
let binding;
const root = resolve(__dirname, '..');
try {
binding = build(root, options);
} catch (e) {
} catch (_e) {
let cmd = 'npm rebuild';
if (existsSync('/run/current-system/nixos-version')) {
cmd = `nix-shell --pure --run "${cmd}"`;
Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function get_dir(...dirs: string[]): Promise<string> {
for (const dir of dirs) {
try {
return await realpath(eval('`' + dir + '`'));
} catch (e) {}
} catch (_e) {}
}
return '';
}
Expand Down Expand Up @@ -52,11 +52,11 @@ export class Config {
// In Android, an ::__fs::filesystem::filesystem_error will be threw
try {
await mkdir(log_dir);
} catch (e) {}
} catch (_e) {}
}
if (typeof shared_data_dir === 'object') shared_data_dir = await get_dir(...shared_data_dir);
if (typeof user_data_dir === 'object') user_data_dir = await get_dir(...user_data_dir);
let traits = {
const traits = {
shared_data_dir: shared_data_dir,
user_data_dir: user_data_dir,
log_dir: log_dir,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
let offset = document.offsetAt(position);
if (offset !== 0 && rime.getCompletionStatus()) {
let inputString = '';
let inputRange: Range = { start: position, end: position };
const inputRange: Range = { start: position, end: position };
const getPrevSingleChar = (offset: number): string => {
return document.getText({
start: document.positionAt(offset - 1),
Expand All @@ -117,7 +117,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
};
let singleChar = getPrevSingleChar(offset);
if (punctMap.has(singleChar)) {
let punctResponse = emptyResponse;
const punctResponse = emptyResponse;
for (const fullWidthPunct of punctMap.get(singleChar)) {
punctResponse.items.push({
label: fullWidthPunct,
Expand Down
2 changes: 1 addition & 1 deletion src/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class SchemaList extends BasicList {
public async loadItems(_context: ListContext): Promise<ListItem[] | null> {
return new Promise<ListItem[] | null>((resolve, _) => {
this.rime.get_schema_list().then((res) => {
let listItems: ListItem[] = res.map((schema) => {
const listItems: ListItem[] = res.map((schema) => {
return {
label: schema.name + ': ' + schema.schema_id,
filterText: schema.name + schema.schema_id,
Expand Down
Loading

0 comments on commit 106aad3

Please sign in to comment.