|
167 | 167 |
|
168 | 168 | ```ts
|
169 | 169 | export interface NewResolver {
|
170 |
| - interfaceVersion: 3; |
171 |
| - name?: string; // This will be included in the debug log |
172 |
| - resolve: (modulePath: string, sourceFile: string) => ResolvedResult; |
| 170 | + interfaceVersion: 3 |
| 171 | + name?: string // This will be included in the debug log |
| 172 | + resolve: (modulePath: string, sourceFile: string) => ResolvedResult |
173 | 173 | }
|
174 | 174 |
|
175 | 175 | // The `ResultNotFound` (returned when not resolved) is the same, no changes
|
176 | 176 | export interface ResultNotFound {
|
177 |
| - found: false; |
178 |
| - path?: undefined; |
| 177 | + found: false |
| 178 | + path?: undefined |
179 | 179 | }
|
180 | 180 |
|
181 | 181 | // The `ResultFound` (returned resolve result) is also the same, no changes
|
182 | 182 | export interface ResultFound {
|
183 |
| - found: true; |
184 |
| - path: string | null; |
| 183 | + found: true |
| 184 | + path: string | null |
185 | 185 | }
|
186 | 186 |
|
187 |
| - export type ResolvedResult = ResultNotFound | ResultFound; |
| 187 | + export type ResolvedResult = ResultNotFound | ResultFound |
188 | 188 | ```
|
189 | 189 |
|
190 | 190 | You will be able to import `NewResolver` from `eslint-plugin-import-x/types`.
|
|
231 | 231 | resolve(mod, source) {
|
232 | 232 | // every time the `resolve` function is called, a new instance is created
|
233 | 233 | // This is very slow
|
234 |
| - const resolverInstance = ResolverFactory.createResolver({}); |
235 |
| - const found = resolverInstance.resolve(mod, {}); |
| 234 | + const resolverInstance = ResolverFactory.createResolver({}) |
| 235 | + const found = resolverInstance.resolve(mod, {}) |
236 | 236 | },
|
237 |
| - }; |
| 237 | + } |
238 | 238 | ```
|
239 | 239 |
|
240 | 240 | With the factory function pattern, you can create a resolver instance beforehand:
|
241 | 241 |
|
242 | 242 | ```js
|
243 |
| - exports.createCustomResolver = (options) => { |
| 243 | + exports.createCustomResolver = options => { |
244 | 244 | // `enhance-resolve` allows you to create a reusable instance:
|
245 |
| - const resolverInstance = ResolverFactory.createResolver({}); |
246 |
| - const resolverInstance = enhanceResolve.create({}); |
| 245 | + const resolverInstance = ResolverFactory.createResolver({}) |
| 246 | + const resolverInstance = enhanceResolve.create({}) |
247 | 247 |
|
248 | 248 | // `oxc-resolver` also allows you to create a reusable instance:
|
249 |
| - const resolverInstance = new ResolverFactory({}); |
| 249 | + const resolverInstance = new ResolverFactory({}) |
250 | 250 |
|
251 | 251 | return {
|
252 |
| - name: "custom-resolver", |
| 252 | + name: 'custom-resolver', |
253 | 253 | interfaceVersion: 3,
|
254 | 254 | resolve(mod, source) {
|
255 | 255 | // the same re-usable instance is shared across `resolve` invocations.
|
256 | 256 | // more performant
|
257 |
| - const found = resolverInstance.resolve(mod, {}); |
| 257 | + const found = resolverInstance.resolve(mod, {}) |
258 | 258 | },
|
259 |
| - }; |
260 |
| - }; |
| 259 | + } |
| 260 | + } |
261 | 261 | ```
|
262 | 262 |
|
263 | 263 | ### Patch Changes
|
|
359 | 359 | - [#122](https://github.com/un-ts/eslint-plugin-import-x/pull/122) [`cd52e86`](https://github.com/un-ts/eslint-plugin-import-x/commit/cd52e86f44754b4dd0c1aae1e9fd5e952e90938f) Thanks [@michaelfaith](https://github.com/michaelfaith)! - Add ESLint flat configuration presets. You can access them with:
|
360 | 360 |
|
361 | 361 | ```ts
|
362 |
| - import eslintPluginImportX from "eslint-plugin-import-x"; |
| 362 | + import eslintPluginImportX from 'eslint-plugin-import-x' |
363 | 363 |
|
364 |
| - eslintPluginImportX.flatConfigs.recommended; |
365 |
| - eslintPluginImportX.flatConfigs.react; |
366 |
| - eslintPluginImportX.flatConfigs.typescript; |
367 |
| - eslintPluginImportX.flatConfigs.electron; |
| 364 | + eslintPluginImportX.flatConfigs.recommended |
| 365 | + eslintPluginImportX.flatConfigs.react |
| 366 | + eslintPluginImportX.flatConfigs.typescript |
| 367 | + eslintPluginImportX.flatConfigs.electron |
368 | 368 | ```
|
369 | 369 |
|
370 | 370 | - [#132](https://github.com/un-ts/eslint-plugin-import-x/pull/132) [`9948c78`](https://github.com/un-ts/eslint-plugin-import-x/commit/9948c7894758dd461f6d75b89c6425fee304789a) Thanks [@SukkaW](https://github.com/SukkaW)! - Added `no-rename-default` that forbid importing a default export by a different name. Originally created by @whitneyit, ported by @SukkaW
|
|
0 commit comments