From 66fcf702acd30dd590bdc27cd0b4e5a7db97b972 Mon Sep 17 00:00:00 2001 From: Susisu Date: Sun, 17 Mar 2024 20:33:05 +0900 Subject: [PATCH] test: update configtest to use flat config --- .../.eslintrc.cjs | 0 configtest/classic/run.sh | 5 +++++ configtest/classic/src/index.tsx | 18 ++++++++++++++++++ configtest/classic/tsconfig.json | 9 +++++++++ configtest/javascript/.eslintrc.cjs | 9 --------- configtest/javascript/eslint.config.js | 10 ++++++++++ configtest/typescript-react/eslint.config.js | 10 ++++++++++ configtest/typescript/.eslintrc.cjs | 9 --------- configtest/typescript/eslint.config.js | 10 ++++++++++ package.json | 1 + 10 files changed, 63 insertions(+), 18 deletions(-) rename configtest/{typescript-react => classic}/.eslintrc.cjs (100%) create mode 100755 configtest/classic/run.sh create mode 100644 configtest/classic/src/index.tsx create mode 100644 configtest/classic/tsconfig.json delete mode 100644 configtest/javascript/.eslintrc.cjs create mode 100644 configtest/javascript/eslint.config.js create mode 100644 configtest/typescript-react/eslint.config.js delete mode 100644 configtest/typescript/.eslintrc.cjs create mode 100644 configtest/typescript/eslint.config.js diff --git a/configtest/typescript-react/.eslintrc.cjs b/configtest/classic/.eslintrc.cjs similarity index 100% rename from configtest/typescript-react/.eslintrc.cjs rename to configtest/classic/.eslintrc.cjs diff --git a/configtest/classic/run.sh b/configtest/classic/run.sh new file mode 100755 index 0000000..3c3fa65 --- /dev/null +++ b/configtest/classic/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +cd $(dirname "$0") +set -eux +eslint --max-warnings 0 src diff --git a/configtest/classic/src/index.tsx b/configtest/classic/src/index.tsx new file mode 100644 index 0000000..0bbc4e4 --- /dev/null +++ b/configtest/classic/src/index.tsx @@ -0,0 +1,18 @@ +export async function foo(): Promise { + const x = await Promise.resolve(42); + return x; +} + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +foo(); +foo().catch((err) => { + const msg = err.toString(); + // eslint-disable-next-line no-console + console.error(msg); +}); + +import React from 'react'; + +export const Foo: React.FC = () => { + return

Hello

; +}; diff --git a/configtest/classic/tsconfig.json b/configtest/classic/tsconfig.json new file mode 100644 index 0000000..b5253cc --- /dev/null +++ b/configtest/classic/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "strict": true, + "lib": ["esnext", "dom"], + "esModuleInterop": true, + "jsx": "react" + }, + "include": ["src/**/*"] +} diff --git a/configtest/javascript/.eslintrc.cjs b/configtest/javascript/.eslintrc.cjs deleted file mode 100644 index 9f95ff9..0000000 --- a/configtest/javascript/.eslintrc.cjs +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - extends: ['@hatena/hatena', '@hatena/hatena/+prettier'], - env: { - node: true, - }, -}; diff --git a/configtest/javascript/eslint.config.js b/configtest/javascript/eslint.config.js new file mode 100644 index 0000000..ea4e04b --- /dev/null +++ b/configtest/javascript/eslint.config.js @@ -0,0 +1,10 @@ +import config from '@hatena/eslint-config-hatena/flat'; +import globals from 'globals'; + +export default config({}, [ + { + languageOptions: { + globals: { ...globals.node }, + }, + }, +]); diff --git a/configtest/typescript-react/eslint.config.js b/configtest/typescript-react/eslint.config.js new file mode 100644 index 0000000..e2a44f8 --- /dev/null +++ b/configtest/typescript-react/eslint.config.js @@ -0,0 +1,10 @@ +import config from '@hatena/eslint-config-hatena/flat'; +import globals from 'globals'; + +export default config({ react: true }, [ + { + languageOptions: { + globals: { ...globals.node }, + }, + }, +]); diff --git a/configtest/typescript/.eslintrc.cjs b/configtest/typescript/.eslintrc.cjs deleted file mode 100644 index 472cb56..0000000 --- a/configtest/typescript/.eslintrc.cjs +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - extends: ['@hatena/hatena', '@hatena/hatena/+typescript', '@hatena/hatena/+prettier'], - env: { - node: true, - }, -}; diff --git a/configtest/typescript/eslint.config.js b/configtest/typescript/eslint.config.js new file mode 100644 index 0000000..ea4e04b --- /dev/null +++ b/configtest/typescript/eslint.config.js @@ -0,0 +1,10 @@ +import config from '@hatena/eslint-config-hatena/flat'; +import globals from 'globals'; + +export default config({}, [ + { + languageOptions: { + globals: { ...globals.node }, + }, + }, +]); diff --git a/package.json b/package.json index e42c646..c36c3ec 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "configtest:javascript": "./configtest/javascript/run.sh", "configtest:typescript": "./configtest/typescript/run.sh", "configtest:typescript-react": "./configtest/typescript-react/run.sh", + "configtest:classic": "./configtest/classic/run.sh", "prepublishOnly": "run-s format:check lint:check typecheck build configtest" }, "dependencies": {