From 568cf66ef2d8c1619cdbaddc107a81d069ce1dac Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Thu, 7 Nov 2024 14:19:51 +0100 Subject: [PATCH] f --- apps/connector/eslint.config.mjs | 9 ++-- apps/connector/src/contents/popup.tsx | 2 +- packages/components/eslint.config.mjs | 10 +--- packages/eslint-config/index.js | 77 ++++++++++++++++----------- packages/eslint-config/util.mjs | 14 ----- packages/icons/eslint.config.mjs | 4 +- 6 files changed, 54 insertions(+), 62 deletions(-) delete mode 100644 packages/eslint-config/util.mjs diff --git a/apps/connector/eslint.config.mjs b/apps/connector/eslint.config.mjs index e98ec45d7..221ad6ac3 100644 --- a/apps/connector/eslint.config.mjs +++ b/apps/connector/eslint.config.mjs @@ -1,12 +1,9 @@ -import config, { tailwindcssConfig } from '@status-im/eslint-config' +import configs, { tailwindcssConfigs } from '@status-im/eslint-config' /** @type {import('eslint').Linter.Config[]} */ export default [ - ...config, - { - ...tailwindcssConfig, - files: ['*.ts', '*.tsx'], - }, + ...configs, + ...tailwindcssConfigs, { files: ['*.ts', '*.tsx'], rules: { diff --git a/apps/connector/src/contents/popup.tsx b/apps/connector/src/contents/popup.tsx index c64806acc..08d3b9842 100644 --- a/apps/connector/src/contents/popup.tsx +++ b/apps/connector/src/contents/popup.tsx @@ -77,7 +77,7 @@ export default function Popup() { -
+
{connected ? : } {showPinInstructions && }
diff --git a/packages/components/eslint.config.mjs b/packages/components/eslint.config.mjs index 0514f1972..13e6322dd 100644 --- a/packages/components/eslint.config.mjs +++ b/packages/components/eslint.config.mjs @@ -1,10 +1,4 @@ -import config, { tailwindcssConfig } from '@status-im/eslint-config' +import configs, { tailwindcssConfigs } from '@status-im/eslint-config' /** @type {import('eslint').Linter.Config[]} */ -export default [ - ...config, - { - ...tailwindcssConfig, - files: ['*.ts', '*.tsx'], - }, -] +export default [...configs, ...tailwindcssConfigs] diff --git a/packages/eslint-config/index.js b/packages/eslint-config/index.js index 2bdb776bb..aa3b5a4b9 100644 --- a/packages/eslint-config/index.js +++ b/packages/eslint-config/index.js @@ -2,7 +2,11 @@ import js from '@eslint/js' import globals from 'globals' -import typescript from 'typescript-eslint' +import { + parser as typescriptParser, + plugin as typescriptPlugin, + configs as typescriptConfigs, +} from 'typescript-eslint' import commentsPlugin from 'eslint-plugin-eslint-comments' import * as importPlugin from 'eslint-plugin-import' import jsxA11yPlugin from 'eslint-plugin-jsx-a11y' @@ -11,29 +15,38 @@ import reactHooksPlugin from 'eslint-plugin-react-hooks' import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort' import prettierPlugin from 'eslint-plugin-prettier/recommended' import tailwindcssPlugin from 'eslint-plugin-tailwindcss' -import { compat } from './util.mjs' /** @type {import('eslint').Linter.Config[]} */ export default [ { name: '@status-im/eslint-config', }, + { + plugins: { + import: importPlugin, + }, + rules: { + ...importPlugin.configs.recommended.rules, + }, + files: [ + '**/*.js', + '**/*.cjs', + '**/*.mjs', + '**/*.jsx', + '**/*.ts', + '**/*.mts', + '**/*.tsx', + '**/*.mdx', + ], // js, ts, mdx + }, { ...js.configs.recommended, - files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], + files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], // js }, - ...typescript.configs.recommended.map(config => ({ + ...typescriptConfigs.recommended.map(config => ({ ...config, - files: ['**/*.ts', '**/*.tsx'], + files: ['**/*.ts', '**/*.mts', '**/*.tsx'], })), - { - ...importPlugin.flatConfigs.recommended, - files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], - }, - { - ...importPlugin.flatConfigs.typescript, - files: ['**/*.ts', '**/*.tsx'], - }, { ...jsxA11yPlugin.flatConfigs.recommended, files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], @@ -42,10 +55,6 @@ export default [ ...reactPlugin.configs.flat['jsx-runtime'], files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], }, - ...compat.extends('plugin:react-hooks/recommended').map(config => ({ - ...config, - files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'], - })), { ...prettierPlugin, files: [ @@ -59,9 +68,9 @@ export default [ ], }, { - files: ['**/*.ts', '**/*.tsx'], + files: ['**/*.ts', '**/*.mts', '**/*.tsx'], // ts languageOptions: { - parser: typescript.parser, + parser: typescriptParser, parserOptions: { // TODO: Enable type-aware linting (https://typescript-eslint.io/docs/linting/type-linting) // "tsconfigRootDir": ".", @@ -78,13 +87,15 @@ export default [ }, }, plugins: { - '@typescript-eslint': typescript.plugin, + '@typescript-eslint': typescriptPlugin, 'eslint-comments': commentsPlugin, react: reactPlugin, 'react-hooks': reactHooksPlugin, 'simple-import-sort': simpleImportSortPlugin, }, rules: { + ...importPlugin.configs.typescript.rules, + ...reactHooksPlugin.configs.recommended.rules, 'react/prop-types': 0, // "@typescript-eslint/consistent-type-definitions": ["error", "interface"], '@typescript-eslint/consistent-type-imports': 'error', @@ -141,19 +152,23 @@ export default [ }, }, }, +] + +/** @type {import('eslint').Linter.Config[]} */ +export const tailwindcssConfigs = [ + { + files: ['**/*.ts', '**/*.mts', '**/*.tsx'], + }, + ...tailwindcssPlugin.configs['flat/recommended'], { - files: ['examples/**/*.tsx'], rules: { - 'react/jsx-uses-react': 'off', - 'react/react-in-jsx-scope': 'off', + 'tailwindcss/classnames-order': 'off', + 'tailwindcss/migration-from-tailwind-2': 'off', + }, + settings: { + tailwindcss: { + callees: ['cx', 'cva'], + }, }, }, ] - -/** @type {import('eslint').Linter.Config} */ -export const tailwindcssConfig = { - ...tailwindcssPlugin.configs['flat/recommended'], - rules: { - 'tailwindcss/classnames-order': 'off', - }, -} diff --git a/packages/eslint-config/util.mjs b/packages/eslint-config/util.mjs deleted file mode 100644 index 61053f509..000000000 --- a/packages/eslint-config/util.mjs +++ /dev/null @@ -1,14 +0,0 @@ -// why: https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -import { FlatCompat } from '@eslint/eslintrc' -import js from '@eslint/js' -import path from 'path' -import { fileURLToPath } from 'url' -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended" -}) - -export { compat } diff --git a/packages/icons/eslint.config.mjs b/packages/icons/eslint.config.mjs index 7247f1e4b..e5cb07bfe 100644 --- a/packages/icons/eslint.config.mjs +++ b/packages/icons/eslint.config.mjs @@ -1,8 +1,8 @@ -import config from '@status-im/eslint-config' +import configs from '@status-im/eslint-config' /** @type {import('eslint').Linter.Config[]} */ export default [ - ...config, + ...configs, { ignores: ['dist', 'index.js', 'index.es.js'], },