From afc90efdc713aef9d2b8d5971fc56806853d2eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Rozs=C3=ADval?= Date: Thu, 26 Oct 2023 15:39:57 +0200 Subject: [PATCH] feat(eslint-config): decompose configs via base config for correctly resolved extensions --- packages/eslint-config/base.js | 1 + packages/eslint-config/src/base.ts | 3 +++ .../eslint-config/src/base/rules/imports.ts | 4 +-- packages/eslint-config/src/index.ts | 5 +--- packages/eslint-config/src/react.ts | 4 +-- packages/eslint-config/src/react/overrides.ts | 25 +++++++++++++++++++ packages/eslint-config/src/react/rules.ts | 5 ---- 7 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 packages/eslint-config/base.js create mode 100644 packages/eslint-config/src/base.ts diff --git a/packages/eslint-config/base.js b/packages/eslint-config/base.js new file mode 100644 index 0000000..2e36896 --- /dev/null +++ b/packages/eslint-config/base.js @@ -0,0 +1 @@ +module.exports = require('./dist/base'); diff --git a/packages/eslint-config/src/base.ts b/packages/eslint-config/src/base.ts new file mode 100644 index 0000000..18e9595 --- /dev/null +++ b/packages/eslint-config/src/base.ts @@ -0,0 +1,3 @@ +import { config } from './base/config'; + +export = config; diff --git a/packages/eslint-config/src/base/rules/imports.ts b/packages/eslint-config/src/base/rules/imports.ts index eadaa4b..f77d9b3 100644 --- a/packages/eslint-config/src/base/rules/imports.ts +++ b/packages/eslint-config/src/base/rules/imports.ts @@ -13,12 +13,12 @@ export const imports = { 'error', { devDependencies: [ + '*.config.js', + '*.config.ts', '/scripts/**/*', '/stories/**/*', '/tests/**/*', '/types/*.d.ts', - 'typedoc.config.js', - 'vitest.config.ts', ], }, ], diff --git a/packages/eslint-config/src/index.ts b/packages/eslint-config/src/index.ts index b7014d5..86ccab2 100644 --- a/packages/eslint-config/src/index.ts +++ b/packages/eslint-config/src/index.ts @@ -1,6 +1,3 @@ -import { config } from './base/config'; - export = { - ...config, - extends: ['airbnb-base', ...config.extends], + extends: ['airbnb-base', './base'], }; diff --git a/packages/eslint-config/src/react.ts b/packages/eslint-config/src/react.ts index 7c3e845..7a96214 100644 --- a/packages/eslint-config/src/react.ts +++ b/packages/eslint-config/src/react.ts @@ -1,8 +1,6 @@ -import { config as base } from './base/config'; import { config as react } from './react/config'; export = { - ...base, ...react, - extends: ['airbnb', ...base.extends, ...react.extends], + extends: ['airbnb', './base', ...react.extends], }; diff --git a/packages/eslint-config/src/react/overrides.ts b/packages/eslint-config/src/react/overrides.ts index 20896cb..89c6b09 100644 --- a/packages/eslint-config/src/react/overrides.ts +++ b/packages/eslint-config/src/react/overrides.ts @@ -9,4 +9,29 @@ export const overrides = [ 'react/jsx-props-no-spreading': 'off', }, }, + { + files: 'next-env.d.ts', + rules: { + 'unicorn/prevent-abbreviations': 'off', + }, + }, + { + files: ['src/pages/**/*.ts', 'src/pages/**/*.tsx'], + rules: { + 'no-restricted-exports': 'off', + 'react/function-component-definition': [ + 'error', + { + namedComponents: ['arrow-function', 'function-declaration'], + unnamedComponents: 'function-expression', + }, + ], + }, + }, + { + files: ['src/pages/_app.tsx', 'src/pages/_document.tsx'], + rules: { + 'react/jsx-props-no-spreading': 'off', + }, + }, ]; diff --git a/packages/eslint-config/src/react/rules.ts b/packages/eslint-config/src/react/rules.ts index bd8b3ca..173998e 100644 --- a/packages/eslint-config/src/react/rules.ts +++ b/packages/eslint-config/src/react/rules.ts @@ -1,9 +1,4 @@ export const rules = { - 'jsx-a11y/anchor-is-valid': [ - 'error', - { components: ['Link'], specialLink: ['onClick', 'onPress'] }, - ], - 'react/function-component-definition': [ 'error', {