Skip to content
Merged
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
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion assets
Submodule assets updated 1 files
+1 −1 package.json
29 changes: 29 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const config = require('eslint-config-hexo/ts');
const testConfig = require('eslint-config-hexo/test');

module.exports = [
// Configurations applied globally
...config,
{
rules: {
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-require-imports': 0
}
},
// Configurations applied only to test files
{
files: [
'test/**/*.ts'
],
languageOptions: {
...testConfig.languageOptions
},
rules: {
...testConfig.rules,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-unused-expressions': 0
}
}
];
4 changes: 2 additions & 2 deletions lib/console/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function initConsole(this: Context, args: InitArgs) {
await spawn('git', ['clone', '--recurse-submodules', '--depth=1', '--quiet', GIT_REPO_URL, target], {
stdio: 'inherit'
});
} catch (err) {
} catch {
log.warn('git clone failed. Copying data instead');
await copyAsset(target);
}
Expand Down Expand Up @@ -85,7 +85,7 @@ async function initConsole(this: Context, args: InitArgs) {
});
}
log.info('Start blogging with Hexo!');
} catch (err) {
} catch {
log.warn(`Failed to install dependencies. Please run 'npm install' in "${target}" folder.`);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/hexo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import goodbye from './goodbye';
import minimist from 'minimist';
import resolve from 'resolve';
import { camelCaseKeys } from 'hexo-util';
// eslint-disable-next-line n/no-missing-import
import registerConsole from './console';
import helpConsole from './console/help';
import initConsole from './console/init';
Expand Down Expand Up @@ -89,7 +90,7 @@ function watchSignal(hexo: Context) {
hexo.unwatch();

hexo.exit().then(() => {
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line n/no-process-exit
process.exit();
});
});
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prepublishOnly": "npm install && npm run clean && npm run build",
"build": "tsc -b",
"clean": "tsc -b --clean",
"eslint": "eslint .",
"eslint": "eslint lib test",
"pretest": "npm run clean && npm run build",
"test": "mocha test/**/*.ts --require ts-node/register",
"test-cov": "nyc --reporter=lcovonly npm test",
Expand Down Expand Up @@ -45,9 +45,9 @@
"abbrev": "^2.0.0",
"bluebird": "^3.7.2",
"command-exists": "^1.2.9",
"hexo-fs": "^4.1.1",
"hexo-fs": "^5.0.1",
"hexo-log": "^4.0.1",
"hexo-util": "^3.3.0",
"hexo-util": "^4.0.0",
"minimist": "^1.2.5",
"picocolors": "^1.0.0",
"resolve": "^1.20.0",
Expand All @@ -64,9 +64,9 @@
"@types/rewire": "^2.5.30",
"@types/sinon": "^17.0.3",
"chai": "^4.3.4",
"eslint": "^8.2.0",
"eslint-config-hexo": "^5.0.0",
"hexo-renderer-marked": "^6.0.0",
"eslint": "^9.39.1",
"eslint-config-hexo": "^6.0.0",
"hexo-renderer-marked": "^7.0.1",
"mocha": "^11.7.5",
"nyc": "^15.1.0",
"rewire": "^9.0.1",
Expand Down
7 changes: 0 additions & 7 deletions test/.eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions test/scripts/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('console', () => {
try {
// @ts-expect-error
consoleExtend.register();
} catch (err) {
} catch (err: any) {
err.should.have.property('message', 'name is required');
}
});
Expand All @@ -19,7 +19,7 @@ describe('console', () => {
try {
// @ts-expect-error
consoleExtend.register('test', 'fn');
} catch (err) {
} catch (err: any) {
err.should.have.property('message', 'fn must be a function');
}
});
Expand All @@ -29,7 +29,7 @@ describe('console', () => {
try {
// @ts-expect-error
consoleExtend.register('test', 'desc', 'fn');
} catch (err) {
} catch (err: any) {
err.should.have.property('message', 'fn must be a function');
}
});
Expand Down
6 changes: 3 additions & 3 deletions test/scripts/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('context', () => {
try {
await hexo.call('wtf');
should.fail();
} catch (err) {
} catch (err: any) {
err.should.have.property('message', 'Console `wtf` has not been registered yet!');
}
});
Expand All @@ -46,7 +46,7 @@ describe('context', () => {
});

it('with callback but no args', done => {
hexo.call('test', err => {
hexo.call('test', (err: any) => {
if (err) return done(err);

spy.calledOnce.should.be.true;
Expand All @@ -57,7 +57,7 @@ describe('context', () => {
});

describe('exit', () => {
let hexo, fatal;
let hexo: Context, fatal: any;

beforeEach(() => {
hexo = new Context();
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { join } from 'path';
import { format } from 'util';
import rewire from 'rewire';
import Context from '../../lib/context';
import console from '../../lib/console';
import console from '../../lib/console/index';
chai.should();

function getConsoleLog({ args }) {
function getConsoleLog({ args }: { args: any[] }) {
return args.map(arr => format(...arr)).join('\n');
}

Expand Down
23 changes: 12 additions & 11 deletions test/scripts/hexo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import chai from 'chai';
import sinon from 'sinon';
import rewire from 'rewire';
import ConsoleExtend from '../../lib/extend/console';
import type Context from '../../lib/context';
chai.should();

require('chai').should();
Expand All @@ -14,7 +15,7 @@ describe('hexo', () => {
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
console_1: {
default: ctx => {
default: (ctx: Context) => {
ctx.extend.console.register('help', spy);
}
}
Expand All @@ -30,7 +31,7 @@ describe('hexo', () => {
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
console_1: {
default: ctx => {
default: (ctx: Context) => {
ctx.extend.console.register('test', spy);
}
}
Expand All @@ -46,7 +47,7 @@ describe('hexo', () => {
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
console_1: {
default: ctx => {
default: (ctx: Context) => {
ctx.extend.console.register('help', spy);
}
}
Expand All @@ -58,11 +59,11 @@ describe('hexo', () => {
});

it('path - number (issue hexo#4334)', async () => {
let args;
let args: Record<string, string>;
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
find_pkg_1: {
default: (_cwd, _args) => {
default: (_cwd: string, _args: { cwd?: string }) => {
args = _args;
return Promise.resolve();
}
Expand All @@ -77,11 +78,11 @@ describe('hexo', () => {
});

it('p - number (issue hexo#4334)', async () => {
let args;
let args: Record<string, string>;
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
find_pkg_1: {
default: (_cwd, _args) => {
default: (_cwd: string, _args: { cwd?: string }) => {
args = _args;
return Promise.resolve();
}
Expand All @@ -96,11 +97,11 @@ describe('hexo', () => {
});

it('slug - number (issue hexo#4334)', async () => {
let args;
let args: Record<string, string>;
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
find_pkg_1: {
default: (_cwd, _args) => {
default: (_cwd: string, _args: { cwd?: string }) => {
args = _args;
return Promise.resolve();
}
Expand All @@ -115,11 +116,11 @@ describe('hexo', () => {
});

it('s - number (issue hexo#4334)', async () => {
let args;
let args: Record<string, string>;
const hexo = rewire('../../dist/hexo');
return hexo.__with__({
find_pkg_1: {
default: (_cwd, _args) => {
default: (_cwd: string, _args: { cwd?: string }) => {
args = _args;
return Promise.resolve();
}
Expand Down
10 changes: 5 additions & 5 deletions test/scripts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ describe('init', () => {
async function rmDir(path: string) {
try {
await rmdir(path);
} catch (err) {
} catch (err: any) {
if (err && err.code === 'ENOENT') return;
throw err;
}
}

function pipeStream(rs, ws) {
function pipeStream(rs: ReturnType<typeof createReadStream>, ws: ReturnType<typeof createSha1Hash>) {
return new Promise((resolve, reject) => {
rs.pipe(ws)
.on('error', reject)
.on('finish', resolve);
});
}

async function compareFile(a, b) {
async function compareFile(a: string, b: string) {
const streamA = createSha1Hash();
const streamB = createSha1Hash();

Expand All @@ -44,7 +44,7 @@ describe('init', () => {
return streamA.read().equals(streamB.read());
}

async function check(path) {
async function check(path: string) {
for (const item of assets) {
const result = await compareFile(
join(assetDir, item),
Expand All @@ -56,7 +56,7 @@ describe('init', () => {

}

function withoutSpawn(fn) {
function withoutSpawn(fn: () => Promise<void>) {
return initModule.__with__({
'spawn_1': () => Promise.reject(new Error('spawn is not available'))
})(fn);
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import rewire from 'rewire';
import { spawn } from 'hexo-util';
chai.should();

function getConsoleLog({ args }) {
function getConsoleLog({ args }: { args: any[] }) {
return args.map(arr => format(...arr)).join('\n');
}

Expand Down