Skip to content

Commit 6581a92

Browse files
committed
chore(repo): migrate to eslint esm
closed COD-268
1 parent 64964d0 commit 6581a92

40 files changed

+206
-163
lines changed

apps/cms/eslint.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

apps/cms/eslint.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
4+
import { fixupConfigRules } from '@eslint/compat';
5+
import { FlatCompat } from '@eslint/eslintrc';
6+
import js from '@eslint/js';
7+
import nx from '@nx/eslint-plugin';
8+
9+
import baseConfig from '../../eslint.config.mjs';
10+
11+
const compat = new FlatCompat({
12+
baseDirectory: dirname(fileURLToPath(import.meta.url)),
13+
recommendedConfig: js.configs.recommended
14+
});
15+
16+
const removeDuplicateImportPlugin = (configArr) => {
17+
for (const config of configArr) {
18+
if (config?.plugins && config?.plugins.import) {
19+
delete config.plugins.import;
20+
}
21+
}
22+
return configArr;
23+
};
24+
25+
const nextPlugins = [
26+
...fixupConfigRules(compat.extends('next')),
27+
...fixupConfigRules(compat.extends('next/core-web-vitals'))
28+
];
29+
30+
const config = [
31+
...baseConfig,
32+
...nx.configs['flat/react-typescript'],
33+
...removeDuplicateImportPlugin(nextPlugins),
34+
{
35+
ignores: ['.next/**/*']
36+
},
37+
{
38+
files: ['src/app/(payload)/**/*'],
39+
rules: {
40+
'@nx/enforce-module-boundaries': 'off'
41+
}
42+
}
43+
];
44+
45+
export default config;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const playwright = require('eslint-plugin-playwright');
1+
import playwright from 'eslint-plugin-playwright';
22

3-
const baseConfig = require('../../eslint.config.js');
3+
import baseConfig from '../../eslint.config.mjs';
44

5-
module.exports = [
5+
export default [
66
playwright.configs['flat/recommended'],
77

88
...baseConfig,
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
const baseConfig = require('../../eslint.config.js');
1+
import importPlugin from 'eslint-plugin-import';
2+
import jsoncParser from 'jsonc-eslint-parser';
23

3-
module.exports = [
4+
import baseConfig from '../../eslint.config.mjs';
5+
6+
export default [
47
...baseConfig,
8+
{
9+
plugins: { import: importPlugin }
10+
},
511
{
612
ignores: ['**/build', '**/server.js', '**/vitest.config.ts.timestamp*']
713
},
@@ -34,7 +40,7 @@ module.exports = [
3440
]
3541
},
3642
languageOptions: {
37-
parser: require('jsonc-eslint-parser')
43+
parser: jsoncParser
3844
}
3945
}
4046
];

e2e/nx-payload-e2e/eslint.config.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import jsoncParser from 'jsonc-eslint-parser';
2+
3+
import baseConfig from '../../eslint.config.mjs';
4+
5+
export default [
6+
...baseConfig,
7+
{
8+
files: ['**/*.json'],
9+
rules: { '@nx/dependency-checks': 'error' },
10+
languageOptions: { parser: jsoncParser }
11+
}
12+
];

e2e/utils/eslint.config.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

e2e/utils/eslint.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import importPlugin from 'eslint-plugin-import';
2+
import jsoncParser from 'jsonc-eslint-parser';
3+
4+
import baseConfig from '../../eslint.config.mjs';
5+
6+
export default [
7+
...baseConfig,
8+
{
9+
plugins: { import: importPlugin }
10+
},
11+
{
12+
files: ['**/*.json'],
13+
rules: { '@nx/dependency-checks': 'error' },
14+
languageOptions: { parser: jsoncParser }
15+
}
16+
];

eslint.config.js renamed to eslint.config.mjs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
const nx = require('@nx/eslint-plugin');
2-
const eslintPluginImport = require('eslint-plugin-import');
1+
import nx from '@nx/eslint-plugin';
2+
import importPlugin from 'eslint-plugin-import';
33

4-
module.exports = [
4+
export default [
55
...nx.configs['flat/base'],
66
...nx.configs['flat/typescript'],
77
...nx.configs['flat/javascript'],
88
{
9-
plugins: {
10-
import: eslintPluginImport
11-
}
9+
plugins: { import: importPlugin }
1210
},
1311
{
1412
ignores: ['**/dist', '**/vite.config.[cm]?ts.timestamp-*.[cm]js']
@@ -128,7 +126,23 @@ module.exports = [
128126
}
129127
]
130128
}
131-
],
129+
]
130+
}
131+
},
132+
{
133+
files: [
134+
'**/*.ts',
135+
'**/*.tsx',
136+
'**/*.js',
137+
'**/*.jsx',
138+
'**/*.mjs',
139+
'**/*.mts'
140+
],
141+
languageOptions: {
142+
ecmaVersion: 'latest',
143+
sourceType: 'module'
144+
},
145+
rules: {
132146
'sort-imports': [
133147
'error',
134148
{

libs/app-cms/feature/seed/eslint.config.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)