Skip to content

Commit

Permalink
chore: 修复 eslint 执行命令配置
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Apr 10, 2024
1 parent 7534c56 commit 3dbfcde
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- macos-latest
- windows-latest
node-version:
- 16
- 18
include:
- node-version: 18
- node-version: 20
os: ubuntu-latest
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
registry-url: https://registry.npmjs.com

- uses: pnpm/action-setup@v2
Expand Down
6 changes: 5 additions & 1 deletion eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = [
languageOptions: {
parserOptions: {
tsconfigRootDir: path.resolve(__dirname),
project: './tsconfig.eslint.json',
project: path.resolve('./tsconfig.eslint.json'),
projectFolderIgnoreList: ['**/node_modules/**', '**/dist/**'],
warnOnUnsupportedTypeScriptVersion: false,
ecmaFeatures: {
Expand All @@ -23,6 +23,9 @@ module.exports = [
sourceType: 'module',
},
},
linterOptions: {
reportUnusedDisableDirectives: false,
},
plugins: {
prettier: require('eslint-plugin-prettier'),
unicorn: require('eslint-plugin-unicorn'),
Expand All @@ -31,6 +34,7 @@ module.exports = [
rules: {
'prettier/prettier': 'warn',
indent: ['off', 2],
'no-console': ['error', { allow: ['warn', 'error'] }],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }],
// TODO
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"build:cjs": "tsc -p tsconfig.cjs.json && node scripts/after-build.mjs",
"build:esm": "tsc -p tsconfig.module.json",
"fix": "run-s fix:*",
"fix:lint": "eslint src --ext .ts --fix",
"fix:lint": "eslint src/**/*.ts --fix",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"test": "run-s test:*",
"test:lint": "eslint src --ext .ts",
"test:lint": "eslint src/*/*.ts",
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
"test:unit": "npm run cov",
"watch": "run-s clean build:cjs && run-p \"build:cjs -- -w\" \"test:unit -- --watch\"",
Expand Down
3 changes: 1 addition & 2 deletions src/lint/eslint-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: lzw
* @Date: 2021-08-15 22:39:01
* @LastEditors: renxia
* @LastEditTime: 2024-04-09 17:37:56
* @LastEditTime: 2024-04-10 10:51:34
* @Description: eslint check
*/

Expand Down Expand Up @@ -121,7 +121,6 @@ export class ESLintCheck extends LintBase<ESLintCheckConfig, ESLintCheckResult>
const fileRules: { [filepath: string]: Record<string, number> } = {};
const fixedFileList = new Set<string>();

// eslint-disable-next-line unicorn/no-array-for-each
results.forEach(result => {
const filePath = fixToshortPath(result.filePath, config.rootDir);

Expand Down
7 changes: 4 additions & 3 deletions src/lint/jira-check.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: lzw
* @Date: 2021-08-15 22:39:01
* @LastEditors: lzw
* @LastEditTime: 2023-02-16 18:02:11
* @LastEditors: renxia
* @LastEditTime: 2024-04-10 10:55:59
* @Description: Jira check
*/

Expand Down Expand Up @@ -59,7 +59,8 @@ export class JiraCheck extends LintBase<JiraCheckConfig, JiraCheckResult> {
const jiraPath = this.getJiraCfgPath(true);

if (jiraPath) {
let jiraConfig = jiraPath.endsWith('.json') ? readJsonFileSync<JiraReqConfig>(jiraPath) : await import(jiraPath);
type JCType = (JiraReqConfig & { default?: JiraReqConfig }) | (() => Promise<JiraReqConfig>);
let jiraConfig: JCType = jiraPath.endsWith('.json') ? readJsonFileSync<JiraReqConfig>(jiraPath) : await import(jiraPath);
if (typeof jiraConfig === 'function') jiraConfig = await jiraConfig();
if (jiraConfig.default) Object.assign(jiraConfig, jiraConfig.default);
if (jiraConfig.cookie) headers.cookie = jiraConfig.cookie;
Expand Down
4 changes: 3 additions & 1 deletion src/lint/prettier-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: lzw
* @Date: 2021-08-15 22:39:01
* @LastEditors: renxia
* @LastEditTime: 2024-01-24 09:15:03
* @LastEditTime: 2024-04-10 10:47:51
* @Description: prettier check
*/

Expand Down Expand Up @@ -179,6 +179,7 @@ export class PrettierCheck extends LintBase<PrettierCheckConfig, PrettierCheckRe
const tipPrefix = item.fixed ? greenBright(`Fixed`) : item.passed ? green('PASS') : red('Failed');
if (!config.silent && !baseConfig.ci) logger.logInline(` - [${tipPrefix}][${index}] ${filepath}`);
} catch (error) {
/* eslint-disable-next-line no-console */
console.log();
logger.error(error);
item.passed = false;
Expand All @@ -187,6 +188,7 @@ export class PrettierCheck extends LintBase<PrettierCheckConfig, PrettierCheckRe
results.push(item);
}

/* eslint-disable-next-line no-console */
console.log();
for (const d of results) {
const shortpath = fixToshortPath(d.filepath, config.rootDir);
Expand Down
8 changes: 6 additions & 2 deletions src/stats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ export async function stats(options: IStatsOption) {

if (options.json) {
const jsonRes = JSON.stringify(result, null, 2);
if (options.jsonFile) writeFileSync(resolve(rootDir, options.jsonFile), jsonRes, 'utf8');
/* eslint-disable no-console */ else console.log(jsonRes);
if (options.jsonFile) {
writeFileSync(resolve(rootDir, options.jsonFile), jsonRes, 'utf8');
} else {
/* eslint-disable-next-line no-console */
console.log(jsonRes);
}
}

logger.info(greenBright(`success!`));
Expand Down
1 change: 0 additions & 1 deletion src/tools/rmdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export async function rmdir(srcs: string[], { slient = false, force = false, dry
}
}

// eslint-disable-next-line unicorn/no-await-expression-member
if (list.length > 0) result = (await concurrency(list, cpus().length)).map(d => d.result);
total = result.filter(Boolean).length;
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/check-git-user-email.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* @Author: renxia
* @Date: 2023-03-23 22:34:36
* @LastEditors: renxia
* @LastEditTime: 2024-04-10 10:48:20
* @Description:
*/
import { color } from 'console-log-colors';
import { existsSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
Expand Down

0 comments on commit 3dbfcde

Please sign in to comment.