diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 81f92af7..00000000 --- a/.eslintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "eslint-config-egg/typescript" - ], - "rules": { - "no-extend-native": "warn" - } -} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 00000000..731f4e85 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,129 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "env": { + "node": true + }, + "extends": [ + "./node_modules/@eggjs/oxlint-config/.oxlintrc.json" + ], + "categories": { + "correctness": "allow", + "suspicious": "allow", + "pedantic": "allow", + "style": "allow", + "nursery": "allow", + "restriction": "allow", + "perf": "allow" + }, + "rules": { + "no-extend-native": "warn", + // Disable TypeScript rules + "typescript/explicit-function-return-type": "allow", + "typescript/consistent-type-imports": "allow", + "typescript/consistent-type-definitions": "allow", + "typescript/consistent-indexed-object-style": "allow", + "typescript/no-inferrable-types": "allow", + "typescript/array-type": "allow", + "typescript/no-non-null-assertion": "allow", + "typescript/no-explicit-any": "allow", + "typescript/no-import-type-side-effects": "allow", + "typescript/no-dynamic-delete": "allow", + "typescript/prefer-ts-expect-error": "allow", + "typescript/ban-ts-comment": "allow", + "typescript/prefer-enum-initializers": "allow", + "typescript/explicit-module-boundary-types": "allow", + // Disable import rules + "import/exports-last": "allow", + "import/max-dependencies": "allow", + "import/no-cycle": "allow", + "import/no-anonymous-default-export": "allow", + "import/no-namespace": "allow", + "import/named": "allow", + "import/export": "allow", + "import/no-default-export": "allow", + "import/unambiguous": "allow", + "import/group-exports": "allow", + "import/extensions": "allow", + "import/consistent-type-specifier-style": "allow", + "import/prefer-default-export": "allow", + "import/no-named-as-default-member": "allow", + // Disable unicorn rules + "unicorn/error-message": "allow", + "unicorn/no-null": "allow", + "unicorn/filename-case": "allow", + "unicorn/prefer-structured-clone": "allow", + "unicorn/prefer-logical-operator-over-ternary": "allow", + "unicorn/prefer-number-properties": "allow", + "unicorn/prefer-array-some": "allow", + "unicorn/prefer-string-slice": "allow", + "unicorn/throw-new-error": "allow", + "unicorn/catch-error-name": "allow", + "unicorn/prefer-spread": "allow", + "unicorn/numeric-separators-style": "allow", + "unicorn/prefer-string-raw": "allow", + "unicorn/text-encoding-identifier-case": "allow", + "unicorn/no-array-for-each": "allow", + "unicorn/explicit-length-check": "allow", + "unicorn/no-lonely-if": "allow", + "unicorn/no-useless-undefined": "allow", + "unicorn/prefer-date-now": "allow", + "unicorn/no-static-only-class": "allow", + "unicorn/no-typeof-undefined": "allow", + "unicorn/prefer-negative-index": "allow", + "unicorn/no-anonymous-default-export": "allow", + "unicorn/consistent-assert": "allow", + // Disable promise rules + "promise/no-return-wrap": "allow", + "promise/param-names": "allow", + "promise/prefer-await-to-callbacks": "allow", + "promise/prefer-await-to-then": "allow", + "promise/prefer-catch": "allow", + "promise/no-return-in-finally": "allow", + "promise/avoid-new": "allow", + // Disable other ESLint rules + "constructor-super": "allow", + "getter-return": "allow", + "no-undef": "allow", + "no-unreachable": "allow", + "no-var": "allow", + "no-eq-null": "allow", + "no-await-in-loop": "allow", + "eqeqeq": "allow", + "init-declarations": "allow", + "curly": "allow", + "no-ternary": "allow", + "max-params": "allow", + "no-await-expression-member": "allow", + "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": "allow", + "no-multi-assign": "allow", + "func-names": "allow", + "default-param-last": "allow", + "prefer-object-spread": "allow", + "no-undefined": "allow", + "no-plusplus": "allow", + "no-console": "allow", + "no-extraneous-class": "allow", + "no-empty-function": "allow", + "max-depth": "allow", + "max-lines-per-function": "allow", + "no-lonely-if": "allow", + "max-lines": "allow", + "require-await": "allow", + "max-nested-callbacks": "allow", + "max-classes-per-file": "allow", + "radix": "allow", + "no-negated-condition": "allow", + "no-else-return": "allow", + "no-throw-literal": "allow", + "id-length": "allow", + "arrow-body-style": "allow", + "prefer-destructuring": "allow" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 612bea3a..c1112480 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "url": "git://github.com/node-modules/urllib.git" }, "scripts": { - "lint": "eslint src test --ext .ts --cache", + "lint": "oxlint src test", "prebuild": "npm run clean", "build": "tsc --version && tshy && tshy-after && npm run build:version", "postbuild": "rm -rf *.tsbuildinfo", @@ -55,6 +55,7 @@ }, "devDependencies": { "@arethetypeswrong/cli": "^0.18.0", + "@eggjs/oxlint-config": "^1.0.0", "@eggjs/tsconfig": "^2.0.0", "@tsconfig/node18": "^18.2.1", "@tsconfig/strictest": "^2.0.2", @@ -69,9 +70,8 @@ "@vitest/coverage-v8": "^3.0.2", "busboy": "^1.6.0", "cross-env": "^10.0.0", - "eslint": "8", - "eslint-config-egg": "14", "iconv-lite": "^0.6.3", + "oxlint": "^1.11.0", "proxy": "^1.0.2", "selfsigned": "^3.0.0", "string.prototype.towellformed": "^1.0.2", diff --git a/test/options.dataType.test.ts b/test/options.dataType.test.ts index 36f32c1b..10ee12c6 100644 --- a/test/options.dataType.test.ts +++ b/test/options.dataType.test.ts @@ -141,7 +141,7 @@ describe('options.dataType.test.ts', () => { }, (err: any) => { // console.error(err); assert.equal(err.name, 'JSONResponseFormatError'); - assert.match(err.message, /\" \.\.\.skip\.\.\. \"/); + assert.match(err.message, /" \.\.\.skip\.\.\. "/); assert.equal(err.res.status, 200); assert.equal(err.res.headers['content-type'], 'application/json'); return true; diff --git a/test/options.fixJSONCtlChars.test.ts b/test/options.fixJSONCtlChars.test.ts index 54b84849..b50bb2ff 100644 --- a/test/options.fixJSONCtlChars.test.ts +++ b/test/options.fixJSONCtlChars.test.ts @@ -24,7 +24,7 @@ describe('options.fixJSONCtlChars.test.ts', () => { assert.equal(response.status, 200); // console.log(response.data); assert.deepEqual(response.data, { - foo: '\b\f\n\r\tbar\u000e!1!\u0086!2\!\u0000\!3\!\u001f\!4\!\\\!5\!end\\\\', + foo: '\b\f\n\r\tbar\u000e!1!\u0086!2!\u0000!3!\u001f!4!\\\!5!end\\\\', }); }); diff --git a/test/user-agent.test.ts b/test/user-agent.test.ts index 3d869e0b..3e6c97a5 100644 --- a/test/user-agent.test.ts +++ b/test/user-agent.test.ts @@ -22,7 +22,7 @@ describe('keep-alive-header.test.ts', () => { }); assert.equal(response.status, 200); // console.log(response.data.headers); - assert.match(response.data.headers['user-agent'], /^node\-urllib\/VERSION Node\.js\/\d+\.\d+\.\d+ \(/); + assert.match(response.data.headers['user-agent'], /^node-urllib\/VERSION Node\.js\/\d+\.\d+\.\d+ \(/); }); it('should return no user agent if user-agent header is set to empty string', async () => {