File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed
packages-backend/eslint-config-node
packages/eslint-config-mc-app Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+
4+ const migrationGuide =
5+ 'node_modules/@commercetools-frontend/eslint-config-node/migrations/v27.md' ;
6+
7+ // Detect if loaded from a legacy .eslintrc file (the array export won't work there)
8+ const caller = module . parent ?. filename || '' ;
9+ if ( / \. e s l i n t r c / . test ( caller ) ) {
10+ console . error (
11+ '\n\u274c @commercetools-frontend/eslint-config-node v27 exports a flat config array.\n' +
12+ ' It cannot be used in .eslintrc files. Migrate to eslint.config.js.\n' +
13+ ' Guide: ' +
14+ migrationGuide +
15+ '\n'
16+ ) ;
17+ }
18+
19+ // Detect leftover legacy config files and warn
20+ const projectRoot = process . cwd ( ) ;
21+ const legacyPatterns = [
22+ '.eslintrc' ,
23+ '.eslintrc.js' ,
24+ '.eslintrc.cjs' ,
25+ '.eslintrc.json' ,
26+ '.eslintrc.yml' ,
27+ '.eslintrc.yaml' ,
28+ ] ;
29+ const foundLegacy = legacyPatterns . filter ( ( name ) =>
30+ fs . existsSync ( path . join ( projectRoot , name ) )
31+ ) ;
32+ if ( foundLegacy . length > 0 ) {
33+ console . warn (
34+ '\n\u26a0\ufe0f @commercetools-frontend/eslint-config-node v27 uses ESLint 9 flat config.\n' +
35+ ` Found legacy config file(s): ${ foundLegacy . join ( ', ' ) } \n` +
36+ ' These files are ignored by ESLint 9 and your subdirectory rules will not be applied.\n' +
37+ ' Guide: ' +
38+ migrationGuide +
39+ '\n'
40+ ) ;
41+ }
42+
143const babelParser = require ( '@babel/eslint-parser' ) ;
244const typescriptPlugin = require ( '@typescript-eslint/eslint-plugin' ) ;
345const typescriptParser = require ( '@typescript-eslint/parser' ) ;
Original file line number Diff line number Diff line change 2828
2929process . env . BABEL_ENV = 'production' ;
3030
31+ const fs = require ( 'fs' ) ;
32+ const path = require ( 'path' ) ;
33+
34+ const migrationGuide =
35+ 'node_modules/@commercetools-frontend/eslint-config-mc-app/migrations/v27.md' ;
36+
37+ // Detect if loaded from a legacy .eslintrc file (the array export won't work there)
38+ const caller = module . parent ?. filename || '' ;
39+ if ( / \. e s l i n t r c / . test ( caller ) ) {
40+ console . error (
41+ '\n\u274c @commercetools-frontend/eslint-config-mc-app v27 exports a flat config array.\n' +
42+ ' It cannot be used in .eslintrc files. Migrate to eslint.config.js.\n' +
43+ ' Guide: ' +
44+ migrationGuide +
45+ '\n'
46+ ) ;
47+ }
48+
49+ // Detect leftover legacy config files and warn
50+ const projectRoot = process . cwd ( ) ;
51+ const legacyPatterns = [
52+ '.eslintrc' ,
53+ '.eslintrc.js' ,
54+ '.eslintrc.cjs' ,
55+ '.eslintrc.json' ,
56+ '.eslintrc.yml' ,
57+ '.eslintrc.yaml' ,
58+ ] ;
59+ const foundLegacy = legacyPatterns . filter ( ( name ) =>
60+ fs . existsSync ( path . join ( projectRoot , name ) )
61+ ) ;
62+ if ( foundLegacy . length > 0 ) {
63+ console . warn (
64+ '\n\u26a0\ufe0f @commercetools-frontend/eslint-config-mc-app v27 uses ESLint 9 flat config.\n' +
65+ ` Found legacy config file(s): ${ foundLegacy . join ( ', ' ) } \n` +
66+ ' These files are ignored by ESLint 9 and your subdirectory rules will not be applied.\n' +
67+ ' Guide: ' +
68+ migrationGuide +
69+ '\n'
70+ ) ;
71+ }
72+
3173const babelParser = require ( '@babel/eslint-parser' ) ;
3274const typescriptPlugin = require ( '@typescript-eslint/eslint-plugin' ) ;
3375const typescriptParser = require ( '@typescript-eslint/parser' ) ;
You can’t perform that action at this time.
0 commit comments