diff --git a/src/plugin_node.mts b/src/plugin_node.mts index bf9edca7..a74b8ecc 100644 --- a/src/plugin_node.mts +++ b/src/plugin_node.mts @@ -29,6 +29,7 @@ function fileExists (f: string): boolean { try { fs.statSync(f) return true + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (err) { return false } @@ -38,6 +39,7 @@ function isDir (f: string): boolean { try { const st = fs.statSync(f) return st.isDirectory() + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (err) { return false } @@ -174,6 +176,7 @@ export default { data = '' }) if (handler !== undefined) { return true } + // eslint-disable-next-line @typescript-eslint/no-unused-vars return new Promise((resolve, _reject) => { const timerCallback = () => { if (sys.tags.readBuffers.length > 0) { @@ -211,6 +214,7 @@ export default { type: 'func', josi: [['を', 'から']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, sys: NakoSystem) { return fs.readFileSync(s) } @@ -242,6 +246,7 @@ export default { type: 'func', josi: [['を', 'から']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, sys: NakoSystem) { // iconv.skipDecodeWarning = true const buf = fs.readFileSync(s) @@ -253,6 +258,7 @@ export default { type: 'func', josi: [['を'], ['へ', 'に']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, f: string, sys: NakoSystem) { // iconv.skipDecodeWarning = true const buf = iconv.encode(s, 'Shift_JIS') @@ -264,6 +270,7 @@ export default { type: 'func', josi: [['を', 'から']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, sys: NakoSystem) { const buf = fs.readFileSync(s) const text = iconv.decode(Buffer.from(buf), 'euc-jp') @@ -274,6 +281,7 @@ export default { type: 'func', josi: [['を'], ['へ', 'に']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, f: string, sys: NakoSystem) { const buf = iconv.encode(s, 'euc-jp') fs.writeFileSync(f, buf) @@ -305,6 +313,7 @@ export default { type: 'func', josi: [['で'], ['を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (callback: any, s: string, sys: NakoSystem) { exec(s, (err, stdout, stderr) => { if (err) { throw new Error(stderr) } else { callback(stdout) } @@ -368,6 +377,7 @@ export default { let st: fs.Stats try { st = fs.statSync(fullpath) + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { continue } @@ -411,6 +421,7 @@ export default { type: 'func', josi: [['から', 'を'], ['に', 'へ']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (a: string, b: string, sys: NakoSystem) { return fse.copySync(a, b) } @@ -419,6 +430,7 @@ export default { type: 'func', josi: [['で'], ['から', 'を'], ['に', 'へ']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (callback: any, a: string, b: string, sys: NakoSystem) { return fse.copy(a, b, (err: any) => { if (err) { throw new Error('ファイルコピー時:' + err) } @@ -431,6 +443,7 @@ export default { type: 'func', josi: [['から', 'を'], ['に', 'へ']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (a: string, b: string, sys: NakoSystem) { return fse.moveSync(a, b) } @@ -439,6 +452,7 @@ export default { type: 'func', josi: [['で'], ['から', 'を'], ['に', 'へ']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (callback: any, a: string, b: string, sys: NakoSystem) { fse.move(a, b, (err: any) => { if (err) { throw new Error('ファイル移動時:' + err) } @@ -451,6 +465,7 @@ export default { type: 'func', josi: [['の', 'を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (path: string, sys: NakoSystem) { return fse.removeSync(path) } @@ -459,6 +474,7 @@ export default { type: 'func', josi: [['で'], ['の', 'を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (callback: any, path: string, sys: NakoSystem) { return fse.remove(path, (err: any) => { if (err) { throw new Error('ファイル削除時:' + err) } @@ -471,6 +487,7 @@ export default { type: 'func', josi: [['の', 'から']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (path: string, sys: NakoSystem) { return fs.statSync(path) } @@ -479,6 +496,7 @@ export default { type: 'func', josi: [['の', 'から']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (path: string, sys: NakoSystem) { const st = fs.statSync(path) if (!st) { return -1 } @@ -594,6 +612,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { // 環境変数からテンポラリフォルダを取得 return os.tmpdir() @@ -603,6 +622,7 @@ export default { type: 'func', josi: [['に', 'へ']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (dir: string, sys: NakoSystem) { if (dir === '' || !dir) { dir = os.tmpdir() @@ -661,6 +681,7 @@ export default { a = sys.tags.__quotePath(a) b = sys.tags.__quotePath(b) const cmd = `${tpath} x ${a} -o${b} -y` + // eslint-disable-next-line @typescript-eslint/no-unused-vars exec(cmd, (err, stdout, stderr) => { if (err) { throw new Error('[エラー]『解凍時』' + err) } callback(stdout) @@ -690,6 +711,7 @@ export default { a = sys.tags.__quotePath(a) b = sys.tags.__quotePath(b) const cmd = `${tpath} a -r ${b} ${a} -y` + // eslint-disable-next-line @typescript-eslint/no-unused-vars exec(cmd, (err, stdout, stderr) => { if (err) { throw new Error('[エラー]『圧縮時』' + err) } callback(stdout) @@ -715,6 +737,7 @@ export default { if (typeof (func) === 'string') { func = sys.__findFunc(func, '強制終了時') } + // eslint-disable-next-line @typescript-eslint/no-unused-vars nodeProcess.on('SIGINT', (signal: any) => { const flag = func(sys) if (flag) { nodeProcess.exit() } @@ -735,6 +758,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { return nodeProcess.platform } @@ -743,6 +767,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { return nodeProcess.arch } @@ -804,7 +829,9 @@ export default { josi: [], pure: true, asyncFn: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem): Promise { + // eslint-disable-next-line @typescript-eslint/no-unused-vars return new Promise((resolve, _reject) => { let dataStr = '' nodeProcess.stdin.on('data', (data: any) => { @@ -822,6 +849,7 @@ export default { type: 'func', josi: [['と'], ['が']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (a: any, b: any, sys: NakoSystem) { assert.strictEqual(a, b) } @@ -831,6 +859,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { const nif = os.networkInterfaces() if (!nif) { throw new Error('『自分IPアドレス取得』でネットワークのインターフェイスが種畜できません。') } @@ -853,6 +882,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { const nif = os.networkInterfaces() if (!nif) { throw new Error('『自分IPアドレス取得』でネットワークのインターフェイスが種畜できません。') } @@ -1011,6 +1041,7 @@ export default { type: 'func', josi: [['まで', 'へ', 'に'], ['を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (url: string, params: [key: string], sys: NakoSystem) { const flist: Array = [] for (const key in params) { @@ -1034,6 +1065,7 @@ export default { type: 'func', josi: [['まで', 'へ', 'に'], ['を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (url: string, params: any, sys: NakoSystem) { const fd = new FormData() for (const key in params) { fd.set(key, params[key]) } @@ -1050,6 +1082,7 @@ export default { type: 'func', josi: [['から'], ['で']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (res: any, type: string, sys: NakoSystem) { type = type.toString().toUpperCase() if (type === 'TEXT' || type === 'テキスト') { @@ -1097,6 +1130,7 @@ export default { type: 'func', josi: [['の', 'を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (params: any, sys: NakoSystem) { const flist: Array = [] for (const key in params) { @@ -1137,6 +1171,7 @@ export default { josi: [['まで', 'へ', 'に'], ['を']], pure: true, asyncFn: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (url: any, params: any, sys: any) { return new Promise((resolve, reject) => { const fd = new FormData() @@ -1227,6 +1262,7 @@ export default { josi: [['へ', 'に'], ['と'], ['を']], pure: true, asyncFn: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: async function (token: string, imageFile: string, message: string, sys: NakoSystem) { const lineNotifyUrl = 'https://notify-api.line.me/api/notify' const formData = new FormData() @@ -1251,6 +1287,7 @@ export default { type: 'func', josi: [['の', 'を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (code: string, sys: NakoSystem) { return iconv.encodingExists(code) } @@ -1259,6 +1296,7 @@ export default { type: 'func', josi: [['に', 'へ', 'を']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (str: string, sys: NakoSystem) { // iconv.skipDecodeWarning = true return iconv.encode(str, 'Shift_JIS') @@ -1268,6 +1306,7 @@ export default { type: 'func', josi: [['から', 'を', 'で']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (buf: any, sys: NakoSystem) { // iconv.skipDecodeWarning = true return iconv.decode(Buffer.from(buf), 'sjis') @@ -1277,6 +1316,7 @@ export default { type: 'func', josi: [['を'], ['へ', 'で']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: string, code: string, sys: NakoSystem) { // iconv.skipDecodeWarning = true return iconv.encode(s, code) @@ -1286,6 +1326,7 @@ export default { type: 'func', josi: [['を'], ['から', 'で']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (buf: any, code: string, sys: NakoSystem) { // iconv.skipDecodeWarning = true return iconv.decode(Buffer.from(buf), code) @@ -1296,6 +1337,7 @@ export default { type: 'func', josi: [], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (sys: NakoSystem) { return crypto.getHashes() } @@ -1304,10 +1346,32 @@ export default { type: 'func', josi: [['を'], ['の'], ['で']], pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars fn: function (s: any, alg: string, enc: any, sys: NakoSystem) { const hashsum = crypto.createHash(alg) hashsum.update(s) return hashsum.digest(enc) } + }, + 'ランダムUUID生成': { // @ランダムに生成された36文字のv4 UUID(文字列)を返す // @ らんだむUUIDせいせい + type: 'func', + josi: [], + pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + fn: function (sys: NakoSystem) { + const uuid = crypto.randomUUID() + return uuid + } + }, + 'ランダム配列生成': { // @暗号強度の強い乱数のバイト配列(Uint8Array)を指定個数返す // @ らんだむはいれつせいせい + type: 'func', + josi: [['の']], + pure: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + fn: function (cnt: number, sys: NakoSystem) { + const a = new Uint8Array(cnt) + crypto.getRandomValues(a) + return a + } } }