@codemod/parser
Advanced tools
Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "@codemod/parser", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Wrapper around @babel/parser that allows parsing everything.", | ||
@@ -20,10 +20,10 @@ "repository": "https://github.com/codemod-js/codemod", | ||
"dependencies": { | ||
"@babel/parser": "^7.15.3" | ||
"@babel/parser": "^7.16.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/types": "^7.15.0", | ||
"@babel/types": "^7.16.0", | ||
"@types/jest": "^25.1.0", | ||
"jest": "^25.1.0", | ||
"ts-jest": "^25.2.1", | ||
"typescript": "^3.6.4" | ||
"jest": "^27.3.1", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
}, | ||
@@ -33,3 +33,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "edf9f0806ed620d374d40428ab894a3878ab6401" | ||
"gitHead": "d716a8fe55c6977d4fa35c8a819d36297e2125ec" | ||
} |
@@ -6,48 +6,48 @@ "use strict"; | ||
test('defaults `sourceType` to "unambiguous"', () => { | ||
expect(__1.buildOptions().sourceType).toBe('unambiguous'); | ||
expect((0, __1.buildOptions)().sourceType).toBe('unambiguous'); | ||
}); | ||
test('defaults `allowAwaitOutsideFunction` to true', () => { | ||
expect(__1.buildOptions().allowAwaitOutsideFunction).toBe(true); | ||
expect((0, __1.buildOptions)().allowAwaitOutsideFunction).toBe(true); | ||
}); | ||
test('defaults `allowImportExportEverywhere` to true', () => { | ||
expect(__1.buildOptions().allowImportExportEverywhere).toBe(true); | ||
expect((0, __1.buildOptions)().allowImportExportEverywhere).toBe(true); | ||
}); | ||
test('defaults `allowReturnOutsideFunction` to true', () => { | ||
expect(__1.buildOptions().allowReturnOutsideFunction).toBe(true); | ||
expect((0, __1.buildOptions)().allowReturnOutsideFunction).toBe(true); | ||
}); | ||
test('defaults `allowSuperOutsideMethod` to true', () => { | ||
expect(__1.buildOptions().allowSuperOutsideMethod).toBe(true); | ||
expect((0, __1.buildOptions)().allowSuperOutsideMethod).toBe(true); | ||
}); | ||
test('defaults `allowUndeclaredExports` to true', () => { | ||
expect(__1.buildOptions().allowUndeclaredExports).toBe(true); | ||
expect((0, __1.buildOptions)().allowUndeclaredExports).toBe(true); | ||
}); | ||
test('includes various plugins by default', () => { | ||
expect(__1.buildOptions().plugins).toBeInstanceOf(Array); | ||
expect((0, __1.buildOptions)().plugins).toBeInstanceOf(Array); | ||
}); | ||
test('includes "typescript" plugin when `sourceFilename` is not present', () => { | ||
expect(__1.buildOptions().plugins).toContain('typescript'); | ||
expect((0, __1.buildOptions)().plugins).toContain('typescript'); | ||
}); | ||
test('includes "flow" plugin when `sourceFilename` is not TypeScript', () => { | ||
expect(__1.buildOptions({ sourceFilename: 'index.js' }).plugins).toContain('flow'); | ||
expect(__1.buildOptions({ sourceFilename: 'index.jsx' }).plugins).toContain('flow'); | ||
expect((0, __1.buildOptions)({ sourceFilename: 'index.js' }).plugins).toContain('flow'); | ||
expect((0, __1.buildOptions)({ sourceFilename: 'index.jsx' }).plugins).toContain('flow'); | ||
}); | ||
test('includes "typescript" plugin when `sourceFilename` is TypeScript', () => { | ||
expect(__1.buildOptions({ sourceFilename: 'index.ts' }).plugins).toContain('typescript'); | ||
expect(__1.buildOptions({ sourceFilename: 'index.tsx' }).plugins).toContain('typescript'); | ||
expect((0, __1.buildOptions)({ sourceFilename: 'index.ts' }).plugins).toContain('typescript'); | ||
expect((0, __1.buildOptions)({ sourceFilename: 'index.tsx' }).plugins).toContain('typescript'); | ||
}); | ||
test('does not include "typescript" plugin when "flow" is already enabled', () => { | ||
expect(__1.buildOptions({ plugins: [['flow', { all: true }]] }).plugins).not.toContain('typescript'); | ||
expect((0, __1.buildOptions)({ plugins: [['flow', { all: true }]] }).plugins).not.toContain('typescript'); | ||
}); | ||
test('does not mix conflicting "recordAndTuple" and "pipelineOperator" plugins', () => { | ||
// adding recordAndTuple to existing plugins | ||
expect(__1.buildOptions({ plugins: [['pipelineOperator', { proposal: 'smart' }]] }) | ||
expect((0, __1.buildOptions)({ plugins: [['pipelineOperator', { proposal: 'smart' }]] }) | ||
.plugins).not.toContainEqual(['recordAndTuple', expect.anything()]); | ||
expect(__1.buildOptions({ | ||
expect((0, __1.buildOptions)({ | ||
plugins: [['pipelineOperator', { proposal: 'hack', topicToken: '#' }]], | ||
}).plugins).not.toContainEqual(['recordAndTuple', expect.anything()]); | ||
expect(__1.buildOptions({ | ||
expect((0, __1.buildOptions)({ | ||
plugins: [['pipelineOperator', { proposal: 'hack', topicToken: '%' }]], | ||
}).plugins).toContainEqual(['recordAndTuple', { syntaxType: 'hash' }]); | ||
// adding pipelineOperator to existing plugins | ||
expect(__1.buildOptions({ plugins: [['recordAndTuple', { syntaxType: 'hash' }]] }) | ||
expect((0, __1.buildOptions)({ plugins: [['recordAndTuple', { syntaxType: 'hash' }]] }) | ||
.plugins).toContainEqual(['pipelineOperator', { proposal: 'minimal' }]); | ||
@@ -57,3 +57,3 @@ }); | ||
const plugins = []; | ||
__1.buildOptions({ plugins }); | ||
(0, __1.buildOptions)({ plugins }); | ||
expect(plugins).toHaveLength(0); | ||
@@ -63,7 +63,7 @@ }); | ||
const options = {}; | ||
__1.buildOptions(options); | ||
(0, __1.buildOptions)(options); | ||
expect(options).toEqual({}); | ||
}); | ||
test('includes "decorators" plugin with options by default', () => { | ||
expect(__1.buildOptions().plugins).toContainEqual([ | ||
expect((0, __1.buildOptions)().plugins).toContainEqual([ | ||
'decorators', | ||
@@ -74,12 +74,12 @@ { decoratorsBeforeExport: true }, | ||
test('does not include "decorators" plugin if "decorators-legacy" is already enabled', () => { | ||
expect(__1.buildOptions({ plugins: ['decorators-legacy'] })).not.toContain('decorators'); | ||
expect((0, __1.buildOptions)({ plugins: ['decorators-legacy'] })).not.toContain('decorators'); | ||
}); | ||
test('enables `topLevelAwait` even if `allowAwaitOutsideFunction` is disabled', () => { | ||
const options = __1.buildOptions({ allowAwaitOutsideFunction: false }); | ||
const options = (0, __1.buildOptions)({ allowAwaitOutsideFunction: false }); | ||
expect(options.plugins).toContain('topLevelAwait'); | ||
expect(__1.parse('await 0', options).program.body[0] | ||
expect((0, __1.parse)('await 0', options).program.body[0] | ||
.expression.type).toEqual('AwaitExpression'); | ||
}); | ||
test('parses with a very broad set of options', () => { | ||
expect(__1.parse(` | ||
expect((0, __1.parse)(` | ||
// demonstrate 'allowReturnOutsideFunction' option and 'throwExpressions' plugin | ||
@@ -113,3 +113,3 @@ return true || throw new Error(a ?? b); | ||
test('allows parsing records and tuples with "bar" syntax', () => { | ||
const tuple = __1.parse(`[|1, 2, {|a: 1|}|]`, { | ||
const tuple = (0, __1.parse)(`[|1, 2, {|a: 1|}|]`, { | ||
plugins: [['recordAndTuple', { syntaxType: 'bar' }]], | ||
@@ -116,0 +116,0 @@ }).program.body[0].expression; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parse = exports.buildOptions = void 0; | ||
const parser_1 = require("@babel/parser"); | ||
@@ -11,5 +12,5 @@ const options_1 = require("./options"); | ||
function parse(input, options) { | ||
return parser_1.parse(input, options_1.default(options)); | ||
return (0, parser_1.parse)(input, (0, options_1.default)(options)); | ||
} | ||
exports.parse = parse; | ||
//# sourceMappingURL=index.js.map |
@@ -14,2 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPluginName = void 0; | ||
const DefaultParserPlugins = new Set([ | ||
@@ -16,0 +17,0 @@ 'asyncGenerators', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35528
328
Updated@babel/parser@^7.16.3