diff --git a/playground/eslint.config.mjs b/playground/eslint.config.mjs index d0cf5cde0..b6bd81180 100644 --- a/playground/eslint.config.mjs +++ b/playground/eslint.config.mjs @@ -6,7 +6,7 @@ import mocha from 'eslint-plugin-mocha'; export default ts.config( eslint.configs.recommended, - ...ts.configs.recommendedTypeChecked, + ...ts.configs.strictTypeChecked, { files: ['*.ts'], languageOptions: { @@ -21,10 +21,11 @@ export default ts.config( files: ['*.ts', '*.mjs'], rules: { eqeqeq: ['error', 'always'], - 'no-constant-condition': ['error', { checkLoops: false }], + '@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }], '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', }, }, mocha.configs.flat.recommended, diff --git a/playground/index.ts b/playground/index.ts index 1c49e6b75..647d5e700 100644 --- a/playground/index.ts +++ b/playground/index.ts @@ -145,6 +145,7 @@ jobs: successMessage.style.display = 'none'; invalidInputMessage.style.display = 'none'; editor.clearGutter('error-marker'); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion window.runActionlint!(editor.getValue()); } @@ -153,7 +154,9 @@ jobs: return; } - debounceId = window.setTimeout(() => startActionlint(), debounceInterval); + debounceId = window.setTimeout(() => { + startActionlint(); + }, debounceInterval); }); function getSource(): string { @@ -192,7 +195,7 @@ jobs: let rest = text; while (true) { const m = rest.match(reUrl); - if (m === null || m.index === undefined || m[0] === undefined) { + if (m === null || m.index === undefined) { if (rest.length > 0) { ret.push(span(rest)); } @@ -212,7 +215,9 @@ jobs: a.rel = 'noopener'; a.textContent = url; a.className = 'has-text-link-my-light is-underlined'; - a.addEventListener('click', e => e.stopPropagation()); + a.addEventListener('click', e => { + e.stopPropagation(); + }); ret.push(a); rest = rest.slice(idx + url.length); @@ -269,12 +274,11 @@ jobs: window.addEventListener('beforeunload', e => { if (contentChanged) { e.preventDefault(); - e.returnValue = ''; } }); checkUrlInput.addEventListener('keyup', e => { - if (e.key === 'Enter' || e.keyCode === 13) { + if (e.key === 'Enter') { e.preventDefault(); checkUrlButton.click(); } @@ -310,7 +314,7 @@ jobs: window.location.hash = b64; }); - preferDark.addListener(event => { + preferDark.addEventListener('change', event => { editor.setOption('theme', colorTheme(event.matches)); }); @@ -327,7 +331,8 @@ jobs: } await go.run(result.instance); -})().catch(err => { +})().catch((err: unknown) => { console.error('ERROR!:', err); - alert(`${err.name}: ${err.message}\n\n${err.stack}`); + const msg = err instanceof Error ? `${err.name}: ${err.message}\n\n${err.stack}` : `Error: ${err}`; + alert(msg); }); diff --git a/playground/test.ts b/playground/test.ts index 89097ebc7..adb869940 100644 --- a/playground/test.ts +++ b/playground/test.ts @@ -76,6 +76,7 @@ jobs: const json = JSON.stringify(errors); assert.equal(errors.length, 1, json); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const err = errors[0]!; assert.equal(err.message, '"runs-on" section is missing in job "test"', `message is unexpected: ${json}`); assert.equal(err.line, 5, `line is unexpected: ${json}`); @@ -101,6 +102,7 @@ jobs: const json = JSON.stringify(errors); assert.equal(errors.length, 1, json); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const err = errors[0]!; assert.ok(err.message.includes('unknown Webhook event "foo"'), `message is unexpected: ${json}`); assert.equal(err.line, 2, `line is unexpected: ${json}`);