@@ -75,10 +75,11 @@ If you are using a plugin in your `eslint.config.js` that is not yet compatible
7575
7676``` js
7777// eslint.config.js - ESM example
78+ import { defineConfig } from " eslint/config" ;
7879import { fixupPluginRules } from " @eslint/compat" ;
7980import somePlugin from " eslint-plugin-some-plugin" ;
8081
81- export default [
82+ export default defineConfig ( [
8283 {
8384 plugins: {
8485 // insert the fixed plugin instead of the original
@@ -88,17 +89,18 @@ export default [
8889 " somePlugin/rule-name" : " error" ,
8990 },
9091 },
91- ];
92+ ]) ;
9293```
9394
9495Or in CommonJS:
9596
9697``` js
9798// eslint.config.js - CommonJS example
99+ const { defineConfig } = require (" eslint/config" );
98100const { fixupPluginRules } = require (" @eslint/compat" );
99101const somePlugin = require (" eslint-plugin-some-plugin" );
100102
101- module .exports = [
103+ module .exports = defineConfig ( [
102104 {
103105 plugins: {
104106 // insert the fixed plugin instead of the original
@@ -108,7 +110,7 @@ module.exports = [
108110 " somePlugin/rule-name" : " error" ,
109111 },
110112 },
111- ];
113+ ]) ;
112114```
113115
114116### Fixing Configs
@@ -117,30 +119,32 @@ If you are importing other configs into your `eslint.config.js` that use plugins
117119
118120``` js
119121// eslint.config.js - ESM example
122+ import { defineConfig } from " eslint/config" ;
120123import { fixupConfigRules } from " @eslint/compat" ;
121124import someConfig from " eslint-config-some-config" ;
122125
123- export default [
126+ export default defineConfig ( [
124127 ... fixupConfigRules (someConfig),
125128 {
126129 // your overrides
127130 },
128- ];
131+ ]) ;
129132```
130133
131134Or in CommonJS:
132135
133136``` js
134137// eslint.config.js - CommonJS example
138+ const { defineConfig } = require (" eslint/config" );
135139const { fixupConfigRules } = require (" @eslint/compat" );
136140const someConfig = require (" eslint-config-some-config" );
137141
138- module .exports = [
142+ module .exports = defineConfig ( [
139143 ... fixupConfigRules (someConfig),
140144 {
141145 // your overrides
142146 },
143- ];
147+ ]) ;
144148```
145149
146150### Including Ignore Files
@@ -151,6 +155,7 @@ The `includeIgnoreFile()` function also accepts a second optional `name` paramet
151155
152156``` js
153157// eslint.config.js - ESM example
158+ import { defineConfig } from " eslint/config" ;
154159import { includeIgnoreFile } from " @eslint/compat" ;
155160import path from " node:path" ;
156161import { fileURLToPath } from " node:url" ;
@@ -159,28 +164,29 @@ const __filename = fileURLToPath(import.meta.url);
159164const __dirname = path .dirname (__filename );
160165const gitignorePath = path .resolve (__dirname , " .gitignore" );
161166
162- export default [
167+ export default defineConfig ( [
163168 includeIgnoreFile (gitignorePath, " Imported .gitignore patterns" ), // second argument is optional.
164169 {
165170 // your overrides
166171 },
167- ];
172+ ]) ;
168173` ` `
169174
170175Or in CommonJS:
171176
172177` ` ` js
173178// eslint.config.js - CommonJS example
179+ const { defineConfig } = require (" eslint/config" );
174180const { includeIgnoreFile } = require (" @eslint/compat" );
175181const path = require (" node:path" );
176182const gitignorePath = path .resolve (__dirname , " .gitignore" );
177183
178- module .exports = [
184+ module .exports = defineConfig ( [
179185 includeIgnoreFile (gitignorePath, " Imported .gitignore patterns" ), // second argument is optional.
180186 {
181187 // your overrides
182188 },
183- ];
189+ ]) ;
184190` ` `
185191
186192**Limitation:** This works without modification when the ignore file is in the same directory as your config file. If the ignore file is in a different directory, you may need to modify the patterns manually.
0 commit comments