Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 2 additions & 131 deletions 133 .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,142 +1,13 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": ["./node_modules/@eggjs/oxlint-config/.oxlintrc.json"],
"env": {
"node": true,
"mocha": true
},
"categories": {
"correctness": "error",
"perf": "error",
"nursery": "error",
"restriction": "error",
"style": "error",
"pedantic": "error",
"suspicious": "error"
},
"plugins": [
"import",
"typescript",
"unicorn",
"jsdoc",
"node",
"promise",
"oxc"
],
"rules": {
// eslint
"constructor-super": "error",
"getter-return": "error",
"no-undef": "error",
"no-unreachable": "error",
"no-var": "error",
"no-eq-null": "error",
"no-await-in-loop": "allow",
"eqeqeq": ["error", "smart"],
"init-declarations": "allow",
"curly": "allow",
"no-ternary": "allow",
"max-params": ["error", 5],
"no-await-expression-member": "error",
"no-continue": "allow",
"guard-for-in": "allow",
"func-style": "allow",
"sort-imports": "allow",
"yoda": "allow",
"sort-keys": "allow",
"no-magic-numbers": "allow",
"no-duplicate-imports": "error",
"no-multi-assign": "error",
"func-names": "error",
"default-param-last": "error",
"prefer-object-spread": "error",
"no-undefined": "allow",
"no-plusplus": "allow",
// maybe warn
"no-console": "warn",
"no-extraneous-class": "allow",
"no-empty-function": "error",
"max-depth": ["error", 6],
"max-lines-per-function": "allow",
"no-lonely-if": "error",
"max-lines": "allow",
"require-await": "allow",
"max-nested-callbacks": ["error", 5],
"max-classes-per-file": "allow",
"radix": "allow",
"no-negated-condition": "error",
"no-else-return": "error",
"no-throw-literal": "error",

// import
"import/exports-last": "allow",
"import/max-dependencies": "allow",
"import/no-cycle": "error",
"import/no-anonymous-default-export": "allow",
"import/no-namespace": "error",
"import/named": "error",
"import/export": "error",
"import/no-default-export": "allow",
"import/unambiguous": "error",

// promise
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/prefer-await-to-callbacks": "error",
"promise/prefer-await-to-then": "error",
"promise/prefer-catch": "error",
"promise/no-return-in-finally": "error",
"promise/avoid-new": "error",

// unicorn
"unicorn/error-message": "error",
"unicorn/no-null": "allow",
"unicorn/filename-case": "allow",
"unicorn/prefer-structured-clone": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-string-slice": "error",
// "unicorn/no-null": "error",
"unicorn/throw-new-error": "error",
"unicorn/catch-error-name": "allow",
"unicorn/prefer-spread": "allow",
"unicorn/numeric-separators-style": "error",
"unicorn/prefer-string-raw": "error",
"unicorn/text-encoding-identifier-case": "error",
"unicorn/no-array-for-each": "error",
"unicorn/explicit-length-check": "error",
"unicorn/no-lonely-if": "error",
"unicorn/no-useless-undefined": "allow",
"unicorn/prefer-date-now": "error",
"unicorn/no-static-only-class": "allow",
"unicorn/no-typeof-undefined": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/no-anonymous-default-export": "allow",

// oxc
"oxc/no-map-spread": "error",
"oxc/no-rest-spread-properties": "allow",
"oxc/no-optional-chaining": "allow",
"oxc/no-async-await": "allow",

// typescript
"typescript/explicit-function-return-type": "allow",
"typescript/consistent-type-imports": "error",
"typescript/consistent-type-definitions": "error",
"typescript/consistent-indexed-object-style": "allow",
"typescript/no-inferrable-types": "error",
"typescript/array-type": "error",
"typescript/no-non-null-assertion": "error",
"typescript/no-explicit-any": "error",
"typescript/no-import-type-side-effects": "error",
"typescript/no-dynamic-delete": "error",
"typescript/prefer-ts-expect-error": "error",
"typescript/ban-ts-comment": "error",
"typescript/prefer-enum-initializers": "error",

// jsdoc
"jsdoc/require-returns": "allow",
"jsdoc/require-param": "allow"
"import/no-unassigned-import": "allow"
},
"ignorePatterns": ["index.d.ts", "test/fixtures/**", "__snapshots__"]
}
8 changes: 5 additions & 3 deletions 8 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"@arethetypeswrong/cli": "^0.17.4",
"@eggjs/bin": "7",
"@eggjs/mock": "^6.0.5",
"@eggjs/oxlint-config": "^1.0.0",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update oxlint to v1 and enable type-aware feature on cli

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated oxlint to v1.14.0 and enabled type-aware features. Added oxlint-tsgolint dependency and configured --type-aware and --tsconfig flags in CLI scripts. The enhanced type-aware linting now detects additional TypeScript issues using the project's tsconfig.json. (f81f26b)

"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "22",
"egg": "4",
"husky": "^9.1.7",
"lint-staged": "^15.5.0",
"oxlint": "^0.16.2",
"oxlint": "^1.14.0",
"oxlint-tsgolint": "^0.1.5",
"prettier": "^3.5.3",
"rimraf": "6",
"snap-shot-it": "^7.9.10",
Expand All @@ -57,7 +59,7 @@
"typescript": "5"
},
"scripts": {
"lint": "oxlint",
"lint": "oxlint --type-aware --tsconfig=./tsconfig.json",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"preci": "npm run clean && npm run lint",
Expand All @@ -71,7 +73,7 @@
"*": "prettier --write --ignore-unknown --cache",
"*.{ts,js,json,md,yml}": [
"prettier --ignore-unknown --write",
"oxlint --fix"
"oxlint --type-aware --tsconfig=./tsconfig.json --fix"
]
},
"type": "module",
Expand Down
12 changes: 6 additions & 6 deletions 12 src/lib/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ function createClient(

if ('cluster' in options && options.cluster === true) {
const config = options as RedisClusterOptions;
assert(
assert.ok(
config.nodes && config.nodes.length > 0,
'[@eggjs/redis] cluster nodes configuration is required when use cluster redis'
);

for (const client of config.nodes) {
assert(
assert.ok(
client.host && client.port,
`[@eggjs/redis] 'host: ${client.host}', 'port: ${client.port}' are required on config`
);
Expand All @@ -47,20 +47,20 @@ function createClient(
client = new RedisClass.Cluster(config.nodes, config);
} else if ('sentinels' in options && options.sentinels) {
const config = options as RedisClientOptions;
assert(
assert.ok(
config.sentinels && config.sentinels.length > 0,
'[@eggjs/redis] sentinels configuration is required when use redis sentinel'
);

for (const sentinel of config.sentinels) {
assert(
assert.ok(
sentinel.host && sentinel.port,
`[@eggjs/redis] 'host: ${sentinel.host}', 'port: ${sentinel.port}' are required on config`
);
}

const mask = config.password ? '***' : config.password;
assert(
assert.ok(
config.name && config.password !== undefined && config.db !== undefined,
`[@eggjs/redis] 'name of master: ${config.name}', 'password: ${mask}', 'db: ${config.db}' are required on config`
);
Expand All @@ -70,7 +70,7 @@ function createClient(
} else {
const config = options as RedisClientOptions;
const mask = config.password ? '***' : config.password;
assert(
assert.ok(
(config.host &&
config.port &&
config.password !== undefined &&
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.