Skip to content

Commit

Permalink
feat: use module-replacements
Browse files Browse the repository at this point in the history
Uses module-replacements package for all replacements rather than
keeping our own copy.
  • Loading branch information
43081j committed Jun 5, 2024
1 parent 5e11d75 commit abf5315
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 344 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"dependencies": {
"fd-package-json": "^1.2.0",
"module-replacements": "^2.0.0",
"semver": "^7.6.0"
}
}
327 changes: 0 additions & 327 deletions src/replacements.ts

This file was deleted.

16 changes: 8 additions & 8 deletions src/rules/ban-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {Rule} from 'eslint';
import {getDocsUrl} from '../util/rule-meta.js';
import {
microUtilities,
microUtilsReplacements,
preferredReplacements,
nativeReplacements,
Replacement
} from '../replacements.js';
type ModuleReplacement
} from 'module-replacements';
import {createReplacementListener} from '../util/imports.js';

interface BanDependenciesOptions {
presets?: string[];
modules?: string[];
}

const availablePresets: Record<string, Replacement[]> = {
microutilities: microUtilities,
native: nativeReplacements,
preferred: preferredReplacements
const availablePresets: Record<string, ModuleReplacement[]> = {
microutilities: microUtilsReplacements.moduleReplacements,
native: nativeReplacements.moduleReplacements,
preferred: preferredReplacements.moduleReplacements
};

const defaultPresets = ['microutilities', 'native', 'preferred'];
Expand Down Expand Up @@ -64,7 +64,7 @@ export const rule: Rule.RuleModule = {
},
create: (context) => {
const options = context.options[0] as BanDependenciesOptions | undefined;
const replacements: Replacement[] = [];
const replacements: ModuleReplacement[] = [];
const presets = options?.presets ?? defaultPresets;
const modules = options?.modules;

Expand Down
Loading

0 comments on commit abf5315

Please sign in to comment.