Skip to content

Commit

Permalink
chore: 升级 ESLint 至 V9
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed May 4, 2024
1 parent 1926b9c commit 40f31c6
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 18 deletions.
70 changes: 70 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// module.exports = [
// ...require('./preset/eslint'),
// ];
const path = require('path');
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');

module.exports = [
...tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: path.resolve(__dirname),
project: path.resolve('./tsconfig.eslint.json'),
projectFolderIgnoreList: ['**/node_modules/**', '**/dist/**'],
warnOnUnsupportedTypeScriptVersion: false,
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2023,
sourceType: 'module',
},
},
linterOptions: {
reportUnusedDisableDirectives: false,
},
plugins: {
prettier: require('eslint-plugin-prettier'),
unicorn: require('eslint-plugin-unicorn'),
},
ignores: ['**/node_modules/**', 'dist/**', 'cjs/**', 'esm/**', 'docs/**', 'mock/**', '**/*.js', '**/*.d.ts'],
rules: {
'prettier/prettier': 'warn',
indent: ['off', 2],
'no-console': ['off', { allow: ['warn', 'error'] }],
'prefer-const': [
'error',
{
destructuring: 'all',
ignoreReadBeforeAssign: false,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }],
// TODO
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/no-await-expression-member': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
},
files: ['src/**/*.ts'],
},
{
files: ['*.js', '*.cjs', '*.mjs'],
...tseslint.configs.disableTypeChecked,
}
),
];
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,27 @@
"cjs"
],
"dependencies": {
"console-log-colors": "^0.4.0",
"console-log-colors": "^0.5.0",
"tslib": "^2.6.2"
},
"devDependencies": {
"@eslint/js": "^9.2.0",
"@iarna/toml": "^2.2.5",
"@jest/core": "^29",
"@jest/types": "^29",
"@lzwme/fed-lint-helper": "^2.5.2",
"@types/eslint": "^8.56.7",
"@lzwme/fed-lint-helper": "^2.6.0",
"@types/eslint": "^8.56.10",
"@types/jest": "^29.5.12",
"@types/micromatch": "^4.0.6",
"@types/node": "^20.12.3",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@types/micromatch": "^4.0.7",
"@types/node": "^20.12.8",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"compressing": "^1.10.0",
"eslint": "^8.57.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-unicorn": "^52.0.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"json5": "^2.2.3",
Expand All @@ -87,8 +88,9 @@
"standard-version": "^9.5.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.12",
"typescript": "^5.4.3",
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0",
"windows-process-tree": "^0.4.0"
},
"peerDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/common/async.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable jest/no-conditional-expect */
/* -eslint-disable jest/no-conditional-expect */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { raceTimeout, sleep, Barrier, getPromiseState, Limiter, ITask, concurrency, retry, wait, Throttler, Sequencer } from './async';

Expand Down Expand Up @@ -159,7 +159,7 @@ describe('async.ts#Sequencer', () => {
});

describe('async.ts#Barrier', () => {
it('should initially be closed', async () => {
it('should initially be closed', () => {
const barrier = new Barrier();
expect(barrier.isOpen()).toBe(false);
});
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('async.ts#sleep', () => {

it('should resolve with the result of a provided async function', async () => {
const value = 'test value from async function';
const result = await sleep(0, async () => value);
const result = await sleep(0, () => value);

expect(result).toBe(value);
});
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('async.ts#Limiter', () => {
}
});

// eslint-disable-next-line jest/no-done-callback
// -eslint-disable-next-line jest/no-done-callback
it('should handle multiple errors correctly', done => {
const errors: Error[] = [];
for (let i = 0; i < 3; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/node/createFilePathFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function createFilePathFilter(options: FilePathFilterOptions = {}) {
extensions = extensions.filter(Boolean).map(d => (d.startsWith('.') ? d : `.${d}`));
}

return function result(id: string | unknown): boolean {
return function result(id: unknown): boolean {
if (typeof id !== 'string') return false;
if (/\0/.test(id)) return false;

Expand Down
2 changes: 1 addition & 1 deletion src/node/ps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function listProcesses(rootPid: number, formatName?: (cmd: string) => str
do {
matches = JS.exec(cmd);
if (matches) {
result += matches + ' ';
result += matches[0] + ' ';
}
} while (matches);

Expand Down

0 comments on commit 40f31c6

Please sign in to comment.