Skip to content

Commit be8f322

Browse files
committed
fix(eslint-config): export single compat config for nest and next
1 parent 9d318b9 commit be8f322

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/eslint-config/src/nestjs/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { FlatCompat } from '@eslint/eslintrc';
22

33
const compat = new FlatCompat({
4-
baseDirectory: process.cwd(),
4+
baseDirectory: import.meta.dirname,
55
});
66

7-
export const config = compat.config({
7+
export const [config] = compat.config({
88
overrides: [
99
{
10-
files: ['src/**/models/**/*.ts'],
10+
files: ['**/src/**/models/**/*.ts'],
1111
rules: {
1212
'import/no-cycle': 'off', // Allow circular dependencies in models as they might reference each other
1313
},
1414
},
1515
{
16-
files: ['src/**/*.ts'],
16+
files: ['**/src/**/*.ts'],
1717
rules: {
1818
'class-methods-use-this': 'off', // Allow class methods that don't use `this` keyword
1919
'no-empty-function': ['error', { allow: ['constructors'] }], // Allow empty constructors for Nest classes

packages/eslint-config/src/nextjs/config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { FlatCompat } from '@eslint/eslintrc';
22

33
const compat = new FlatCompat({
4-
baseDirectory: process.cwd(),
4+
baseDirectory: import.meta.dirname,
55
});
66

7-
export const config = compat.config({
7+
export const [config] = compat.config({
88
extends: ['plugin:@next/next/recommended'],
99
plugins: ['@next/next'],
1010
settings: {
@@ -14,13 +14,13 @@ export const config = compat.config({
1414
},
1515
overrides: [
1616
{
17-
files: ['next-env.d.ts'],
17+
files: ['**/next-env.d.ts'],
1818
rules: {
1919
'unicorn/prevent-abbreviations': 'off', // next-env.d.ts is a Next.js convention
2020
},
2121
},
2222
{
23-
files: ['src/app/**/*.ts', 'app/**/*.tsx', 'src/pages/**/*.ts', 'src/pages/**/*.tsx'],
23+
files: ['**/src/app/**/*.ts', '**/src/app/**/*.tsx', '**/src/pages/**/*.ts', '**/src/pages/**/*.tsx'],
2424
rules: {
2525
'react/function-component-definition': [
2626
// Allow components as function declarations in Next.js App and Page components for shorthand default exports
@@ -33,19 +33,19 @@ export const config = compat.config({
3333
},
3434
},
3535
{
36-
files: ['src/app/**/layout.tsx', 'src/**/layouts/**/*.tsx'],
36+
files: ['**/src/app/**/layout.tsx', '**/src/**/layouts/**/*.tsx'],
3737
rules: {
3838
'@next/next/no-head-element': 'off', // Allow <head/> element in Next.js App layouts
3939
},
4040
},
4141
{
42-
files: ['src/**/layouts/**/*.tsx', 'src/pages/_app.tsx', 'src/pages/_document.tsx'],
42+
files: ['**/src/**/layouts/**/*.tsx', '**/src/pages/_app.tsx', '**/src/pages/_document.tsx'],
4343
rules: {
4444
'react/jsx-props-no-spreading': 'off', // Allow spreading props in Next.js App layouts, _app.tsx and _document.tsx
4545
},
4646
},
4747
{
48-
files: ['src/**/actions.ts'],
48+
files: ['**/src/**/actions.ts'],
4949
rules: {
5050
'@typescript-eslint/require-await': 'off', // Next.js Server Actions must be async but don't need to await
5151
},

0 commit comments

Comments
 (0)