Skip to content

Commit

Permalink
fix: ignore ambient babelrc config files (#17)
Browse files Browse the repository at this point in the history
There may be a `.babelrc` file in the project where `codemod` is run, but it should not pick up its contents and use the plugins/presets it defines when running. For some reason this wasn't an issue in v1.1.2, but showed up in v1.1.3.
  • Loading branch information
eventualbuddha authored May 12, 2017
1 parent 3109acd commit ba6b8d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TransformRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class TransformRunner {
private transformSource(source: Source): string {
return transform(source.content, {
filename: source.path,
babelrc: false,
parserOpts: {
parser(code: string) {
return parse(
Expand Down
11 changes: 11 additions & 0 deletions test/TransformRunnerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ describe('TransformRunner', function() {
);
});

it('does not include any plugins not specified explicitly', function() {
let source = new Source('a.js', 'export default 0;\n');
let runner = new TransformRunner([source], []);
let result = Array.from(runner.run());

deepEqual(
result,
[new SourceTransformResult(source, 'export default 0;\n', null)]
);
});

it('allows running plugins with options', function() {
let source = new Source('a.js', '3 + 4;');
let plugin = function(babel: typeof Babel) {
Expand Down

0 comments on commit ba6b8d7

Please sign in to comment.