Skip to content

Commit 9c73d1a

Browse files
author
Robert Jackson
authored
Merge pull request #117 from mydea/disallowlist
2 parents 8199eef + fad7372 commit 9c73d1a

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

__tests__/index-test.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe(`ember-modules-api-polyfill-reexport`, () => {
179179

180180
// Ensure unknown exports are not removed
181181
describe(`unknown imports from known module`, () => {
182-
it(`allows blacklisting import paths`, () => {
182+
it(`allows disallowing import paths`, () => {
183183
let input = `import { derp } from '@ember/object/computed';`;
184184

185185
expect(() => {
@@ -210,22 +210,20 @@ export { capitalize };`
210210
});
211211

212212
describe('options', () => {
213-
describe('blacklist', () => {
214-
it(`allows blacklisting import paths`, () => {
213+
describe('ignore', () => {
214+
it(`allows ignoring import paths`, () => {
215215
let input = `import { assert } from '@ember/debug';`;
216-
let actual = transform(input, [
217-
[Plugin, { blacklist: ['@ember/debug'] }],
218-
]);
216+
let actual = transform(input, [[Plugin, { ignore: ['@ember/debug'] }]]);
219217

220218
expect(actual).toEqual(input);
221219
});
222220

223-
it(`allows blacklisting specific named imports`, () => {
221+
it(`allows ignoring specific named imports`, () => {
224222
let input = `import { assert, inspect } from '@ember/debug';var _x = inspect`;
225223
let actual = transform(input, [
226224
[
227225
Plugin,
228-
{ blacklist: { '@ember/debug': ['assert', 'warn', 'deprecate'] } },
226+
{ ignore: { '@ember/debug': ['assert', 'warn', 'deprecate'] } },
229227
],
230228
]);
231229

@@ -234,9 +232,9 @@ describe('options', () => {
234232
);
235233
});
236234

237-
it('does not error when a blacklist is not present', () => {
235+
it('does not error when ignore is not present', () => {
238236
let input = `import { assert, inspect } from '@ember/debug';var _x = assert; var _y = inspect;`;
239-
let actual = transform(input, [[Plugin, { blacklist: {} }]]);
237+
let actual = transform(input, [[Plugin, { ignore: {} }]]);
240238

241239
expect(actual).toEqual(`var _x = Ember.assert;var _y = Ember.inspect;`);
242240
});

src/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
const path = require('path');
44
const mapping = require('ember-rfc176-data');
55

6-
function isBlacklisted(blacklist, importPath, exportName) {
7-
if (Array.isArray(blacklist)) {
8-
return blacklist.indexOf(importPath) > -1;
6+
function isIgnored(ignore, importPath, exportName) {
7+
if (Array.isArray(ignore)) {
8+
return ignore.indexOf(importPath) > -1;
99
} else {
10-
let blacklistedExports = blacklist[importPath];
10+
let ignoredExports = ignore[importPath];
1111

12-
return blacklistedExports && blacklistedExports.indexOf(exportName) > -1;
12+
return ignoredExports && ignoredExports.indexOf(exportName) > -1;
1313
}
1414
}
1515

@@ -67,7 +67,7 @@ module.exports = function (babel) {
6767
name: 'ember-modules-api-polyfill',
6868
visitor: {
6969
ImportDeclaration(path, state) {
70-
let blacklist = (state.opts && state.opts.blacklist) || [];
70+
let ignore = (state.opts && state.opts.ignore) || [];
7171
let node = path.node;
7272
let declarations = [];
7373
let removals = [];
@@ -134,7 +134,7 @@ module.exports = function (babel) {
134134
importName = imported.name;
135135
}
136136

137-
if (isBlacklisted(blacklist, importPath, importName)) {
137+
if (isIgnored(ignore, importPath, importName)) {
138138
return;
139139
}
140140

@@ -188,7 +188,7 @@ module.exports = function (babel) {
188188
},
189189

190190
ExportNamedDeclaration(path, state) {
191-
let blacklist = (state.opts && state.opts.blacklist) || [];
191+
let ignore = (state.opts && state.opts.ignore) || [];
192192
let node = path.node;
193193
if (!node.source) {
194194
return;
@@ -224,7 +224,7 @@ module.exports = function (babel) {
224224
// Determine the import name, either default or named
225225
let importName = local.name;
226226

227-
if (isBlacklisted(blacklist, importPath, importName)) {
227+
if (isIgnored(ignore, importPath, importName)) {
228228
return;
229229
}
230230

0 commit comments

Comments
 (0)