Skip to content

Commit

Permalink
feat(eslint-config): decompose configs via base config for correctly …
Browse files Browse the repository at this point in the history
…resolved extensions
  • Loading branch information
rozsival committed Oct 26, 2023
1 parent 552d6cc commit afc90ef
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/base');
3 changes: 3 additions & 0 deletions packages/eslint-config/src/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { config } from './base/config';

export = config;
4 changes: 2 additions & 2 deletions packages/eslint-config/src/base/rules/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
],
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { config } from './base/config';

export = {
...config,
extends: ['airbnb-base', ...config.extends],
extends: ['airbnb-base', './base'],
};
4 changes: 1 addition & 3 deletions packages/eslint-config/src/react.ts
Original file line number Diff line number Diff line change
@@ -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],
};
25 changes: 25 additions & 0 deletions packages/eslint-config/src/react/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
];
5 changes: 0 additions & 5 deletions packages/eslint-config/src/react/rules.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export const rules = {
'jsx-a11y/anchor-is-valid': [
'error',
{ components: ['Link'], specialLink: ['onClick', 'onPress'] },
],

'react/function-component-definition': [
'error',
{
Expand Down

0 comments on commit afc90ef

Please sign in to comment.