Skip to content

Commit 846aac0

Browse files
hakatashiclaude
andcommitted
fix: Vitest移行後のコードスタイルとSonarQube問題を修正
- モックファイル(__mocks__/*.js)の先頭空行を除去 - 各テストファイルのimport文をvi.mockより前に移動(Vitestのhoistingを活用) - 不要なeslint-disable/eslint-envコメントを削除 - lyrics/index.test.ts: scrapeHTML + HTMLコンテンツを使った元のテストロジックに近い形に復元 - shogi/index.ts: parseInt()由来の値のみのSQL文字列補間にNOSONARを追加 - vocabwar/index.ts: querySelector/matchのnullデリファレンスをoptional chainingで修正 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fdbd0bc commit 846aac0

36 files changed

Lines changed: 123 additions & 141 deletions

__mocks__/axios.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const {PassThrough} = require('stream');
32

43
const axios = vi.fn((options = {}) => {

__mocks__/download.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const download = vi.fn((options) => Promise.resolve(download.response));
32
download.get = download;
43
download.post = download;

__mocks__/fs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const fs = {};
32
const realFs = require('fs');
43
const Path = require('path');

__mocks__/sqlite.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const sqlite = {};
32

43
sqlite.open = vi.fn(() => ({

__mocks__/tinyreq.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const {PassThrough} = require('stream');
32

43
const tinyreq = (...args) => (

__mocks__/word2vec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
class Model {
32
similarity() {
43
return 0;

auto-archiver/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import {SectionBlock} from '@slack/web-api';
32
import {noop} from 'lodash';
43
import schedule, {Job, JobCallback} from 'node-schedule';

checkin/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
vi.mock('axios');
2-
31
import axios from 'axios';
42
import Slack from '../lib/slackMock';
53
import checkin from './index.js';
64

5+
vi.mock('axios');
6+
77
let slack: InstanceType<typeof Slack> = null;
88

99
beforeEach(() => {

discord/notifier.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* eslint-disable import/imports-first */
2-
/* eslint-disable import/first */
1+
import {GuildMember, User, VoiceChannel, VoiceState} from 'discord.js';
2+
import Slack from '../lib/slackMock';
3+
import {Notifier} from './notifier';
34

45
vi.mock('../lib/state');
56
vi.mock('../lib/slack');
@@ -9,10 +10,6 @@ vi.mock('node-schedule', () => ({
910
scheduleJob: vi.fn(),
1011
}));
1112

12-
import {GuildMember, User, VoiceChannel, VoiceState} from 'discord.js';
13-
import Slack from '../lib/slackMock';
14-
import {Notifier} from './notifier';
15-
1613
describe('discord', () => {
1714
describe('Notifier', () => {
1815
const FAKE_SANDBOX = 'C12345678';

jantama/util.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import {extractMajsoulId} from './util';
32

43
describe('extractMajsoulId', () => {

0 commit comments

Comments
 (0)