Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemod/parser

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemod/parser - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

27

CHANGELOG.md

@@ -6,38 +6,33 @@ # Change Log

## [1.0.3](https://github.com/codemod-js/codemod/compare/@codemod/parser@1.0.2...@codemod/parser@1.0.3) (2019-08-09)
## [1.0.7](https://github.com/codemod-js/codemod/compare/@codemod/parser@1.0.5...@codemod/parser@1.0.7) (2020-03-25)
### Bug Fixes
* **license:** update outdated license files ([58e4b11](https://github.com/codemod-js/codemod/commit/58e4b11))
- ensure `topLevelAwait` plugin is enabled ([fc07ce5](https://github.com/codemod-js/codemod/commit/fc07ce5edfe465938a24e59a5e4e9b851ca7e645))
- update babel dependencies ([0d9d569](https://github.com/codemod-js/codemod/commit/0d9d56985dbc5d47621073561cd1617116685e5d))
- upgrade babel to 7.9.0 ([bfdc402](https://github.com/codemod-js/codemod/commit/bfdc402a6ec0d5a1068c02c07107e8f7148e8a1a))
- upgrade prettier ([4a22030](https://github.com/codemod-js/codemod/commit/4a22030af417911cad1efe44111f9da38c1cc102))
## [1.0.3](https://github.com/codemod-js/codemod/compare/@codemod/parser@1.0.2...@codemod/parser@1.0.3) (2019-08-09)
### Bug Fixes
- **license:** update outdated license files ([58e4b11](https://github.com/codemod-js/codemod/commit/58e4b11))
## [1.0.2](https://github.com/codemod-js/codemod/compare/@codemod/parser@1.0.1...@codemod/parser@1.0.2) (2019-08-09)
### Bug Fixes
* **package:** add "types" to package.json ([094d504](https://github.com/codemod-js/codemod/commit/094d504))
- **package:** add "types" to package.json ([094d504](https://github.com/codemod-js/codemod/commit/094d504))
## [1.0.1](https://github.com/codemod-js/codemod/compare/@codemod/parser@1.0.0...@codemod/parser@1.0.1) (2019-08-07)
### Bug Fixes
* fix: add more parsing plugins ([420c7db](https://github.com/codemod-js/codemod/commit/420c7db))
- fix: add more parsing plugins ([420c7db](https://github.com/codemod-js/codemod/commit/420c7db))
## [1.0.0](https://github.com/codemod-js/codemod/commit/26fe442) (2019-07-31)
### Features
* initial commit of [@codemod/parser](https://github.com/codemod/parser) ([84de839](https://github.com/codemod-js/codemod/commit/26fe442))
- initial commit of [@codemod/parser](https://github.com/codemod/parser) ([84de839](https://github.com/codemod-js/codemod/commit/26fe442))
{
"name": "@codemod/parser",
"version": "1.0.6",
"version": "1.0.7",
"description": "Wrapper around @babel/parser that allows parsing everything.",

@@ -8,2 +8,4 @@ "repository": "https://github.com/codemod-js/codemod",

"author": "Brian Donovan",
"main": "src/index.js",
"types": "src/index.d.ts",
"files": [

@@ -14,4 +16,2 @@ "src/**/*.js",

],
"main": "src/index.js",
"types": "src/index.d.ts",
"scripts": {

@@ -22,9 +22,9 @@ "prepare": "tsc",

"dependencies": {
"@babel/parser": "^7.8.0"
"@babel/parser": "^7.9.0"
},
"devDependencies": {
"@babel/types": "^7.7.4",
"@types/jest": "^24.0.16",
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"@babel/types": "^7.9.0",
"@types/jest": "^25.1.0",
"jest": "^25.1.0",
"ts-jest": "^25.2.1",
"typescript": "^3.6.4"

@@ -35,3 +35,3 @@ },

},
"gitHead": "4ff0bc38d0ce48f3251aa990eb72e1cb71be9913"
"gitHead": "4defbeebe889c411b4ef04d33ae1588a3ed1633c"
}

@@ -16,5 +16,5 @@ # @codemod/parser

```ts
import { parse } from '@codemod/parser';
import { parse } from '@codemod/parser'
console.log(parse('a ?? b').program.body[0].expression.operator); // '??'
console.log(parse('a ?? b').program.body[0].expression.operator) // '??'
```

@@ -21,0 +21,0 @@

@@ -53,3 +53,3 @@ "use strict";

'decorators',
{ decoratorsBeforeExport: true }
{ decoratorsBeforeExport: true },
]);

@@ -80,3 +80,5 @@ });

a(?, b)
`).program.body.map(node => t.isExpressionStatement(node) ? node.expression.type : node.type)).toEqual([
// demonstrate 'recordAndTuple' plugin
#[1, 2, #{a: 3}]
`).program.body.map((node) => t.isExpressionStatement(node) ? node.expression.type : node.type)).toEqual([
'ReturnStatement',

@@ -87,5 +89,13 @@ 'ExportNamedDeclaration',

'AssignmentExpression',
'CallExpression'
'CallExpression',
'TupleExpression',
]);
});
test('allows parsing records and tuples with "bar" syntax', () => {
const tuple = __1.parse(`[|1, 2, {|a: 1|}|]`, {
plugins: [['recordAndTuple', { syntaxType: 'bar' }]],
}).program.body[0].expression;
expect(t.isTupleExpression(tuple)).toBe(true);
expect(t.isRecordExpression(tuple.elements[2])).toBe(true);
});
//# sourceMappingURL=test.js.map

@@ -5,6 +5,6 @@ import { ParserOptions as BabelParserOptions, ParserPlugin as BabelParserPlugin } from '@babel/parser';

*/
export declare type ParserPlugin = BabelParserPlugin | 'logicalAssignment' | 'partialApplication' | 'placeholders';
export declare type ParserPlugin = BabelParserPlugin | ['recordAndTuple', {
syntaxType: 'hash' | 'bar';
}];
export interface ParserOptions extends Omit<BabelParserOptions, 'plugins'> {
allowUndeclaredExports?: boolean;
sourceFileName?: string;
plugins?: Array<ParserPlugin>;

@@ -16,2 +16,2 @@ }

*/
export default function buildOptions({ sourceType, allowAwaitOutsideFunction, allowImportExportEverywhere, allowReturnOutsideFunction, allowSuperOutsideMethod, allowUndeclaredExports, plugins, sourceFilename, sourceFileName, ...rest }?: ParserOptions): ParserOptions;
export default function buildOptions({ sourceType, allowAwaitOutsideFunction, allowImportExportEverywhere, allowReturnOutsideFunction, allowSuperOutsideMethod, allowUndeclaredExports, plugins, sourceFilename, ...rest }?: ParserOptions): ParserOptions;

@@ -39,3 +39,4 @@ "use strict";

['decorators', { decoratorsBeforeExport: true }],
['pipelineOperator', { proposal: 'smart' }]
['pipelineOperator', { proposal: 'smart' }],
['recordAndTuple', { syntaxType: 'hash' }],
]);

@@ -47,3 +48,3 @@ /**

function buildOptions(_a = {}) {
var { sourceType = 'unambiguous', allowAwaitOutsideFunction = true, allowImportExportEverywhere = true, allowReturnOutsideFunction = true, allowSuperOutsideMethod = true, allowUndeclaredExports = true, plugins = [], sourceFilename, sourceFileName } = _a, rest = __rest(_a, ["sourceType", "allowAwaitOutsideFunction", "allowImportExportEverywhere", "allowReturnOutsideFunction", "allowSuperOutsideMethod", "allowUndeclaredExports", "plugins", "sourceFilename", "sourceFileName"]);
var { sourceType = 'unambiguous', allowAwaitOutsideFunction = true, allowImportExportEverywhere = true, allowReturnOutsideFunction = true, allowSuperOutsideMethod = true, allowUndeclaredExports = true, plugins = [], sourceFilename } = _a, rest = __rest(_a, ["sourceType", "allowAwaitOutsideFunction", "allowImportExportEverywhere", "allowReturnOutsideFunction", "allowSuperOutsideMethod", "allowUndeclaredExports", "plugins", "sourceFilename"]);
for (const plugin of DefaultParserPlugins) {

@@ -54,5 +55,3 @@ if (shouldAddPlugin(plugins, getPluginName(plugin))) {

}
const typePlugin = typePluginForSourceFileName(
// https://github.com/babel/babel/pull/10291
sourceFileName || sourceFilename);
const typePlugin = typePluginForSourceFileName(sourceFilename);
if (shouldAddPlugin(plugins, typePlugin)) {

@@ -68,4 +67,3 @@ plugins = [...plugins, typePlugin];

plugins,
sourceFilename,
sourceFileName }, rest);
sourceFilename }, rest);
}

@@ -122,3 +120,3 @@ exports.default = buildOptions;

}
return !getMutuallyExclusivePluginsForPlugin(name).some(mutuallyExclusivePlugin => pluginListIncludesPlugin(plugins, mutuallyExclusivePlugin));
return !getMutuallyExclusivePluginsForPlugin(name).some((mutuallyExclusivePlugin) => pluginListIncludesPlugin(plugins, mutuallyExclusivePlugin));
}

@@ -135,3 +133,3 @@ /**

function pluginListIncludesPlugin(plugins, name) {
return plugins.some(entry => getPluginName(entry) === name);
return plugins.some((entry) => getPluginName(entry) === name);
}

@@ -138,0 +136,0 @@ /**

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc