New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslump

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslump - npm Package Compare versions

Comparing version 1.6.2 to 2.0.0

src/cli-program.js

20

CHANGELOG.md

@@ -0,1 +1,9 @@

### Version 2.0.0 (2018-12-02)
- Fixed: Test files provided to the CLI are now resolved relative to CWD as
expected.
- Changed: Dropped support for Node.js 4.
- Improved: Updated dependencies.
- Improved: Added some tests.
### Version 1.6.2 (2018-04-23)

@@ -9,3 +17,2 @@

### Version 1.6.1 (2018-03-12)

@@ -19,3 +26,2 @@

### Version 1.6.0 (2017-06-26)

@@ -27,3 +33,2 @@

### Version 1.5.1 (2017-03-26)

@@ -34,3 +39,2 @@

### Version 1.5.0 (2017-03-25)

@@ -43,3 +47,2 @@

### Version 1.4.0 (2017-02-06)

@@ -50,3 +53,2 @@

### Version 1.3.1 (2017-02-04)

@@ -56,3 +58,2 @@

### Version 1.3.0 (2017-02-04)

@@ -63,3 +64,2 @@

### Version 1.2.0 (2017-02-03)

@@ -73,3 +73,2 @@

### Version 1.1.1 (2017-01-30)

@@ -79,3 +78,2 @@

### Version 1.1.0 (2017-01-30)

@@ -85,3 +83,2 @@

### Version 1.0.0 (2017-01-28)

@@ -91,3 +88,2 @@

[#5]: https://github.com/lydell/eslump/issues/5

59

package.json
{
"name": "eslump",
"version": "1.6.2",
"version": "2.0.0",
"license": "MIT",

@@ -18,19 +18,21 @@ "author": "Simon Lydell",

],
"main": "src/index.js",
"bin": {
"eslump": "cli-runner.js"
"eslump": "src/cli-runner.js"
},
"files": [
"cli-program.js",
"cli-runner.js",
"codegen.js",
"index.js",
"random.js"
"src"
],
"repository": "lydell/eslump",
"scripts": {
"test": "eslint .",
"test-fix": "npm run test -- --fix"
"eslint": "eslint .",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "prettier --write \"*.md\"",
"doctoc": "doctoc README.md",
"jest": "jest",
"test": "npm run eslint && npm run jest",
"prepublishOnly": "npm test"
},
"dependencies": {
"@babel/code-frame": "^7.0.0-beta.46",
"@babel/code-frame": "^7.0.0",
"mkdirp": "^0.5.1",

@@ -42,21 +44,26 @@ "optionator": "^0.8.2",

"shift-fuzzer": "^1.0.2",
"shift-reducer": "^4.3.0"
"shift-reducer": "^5.0.0"
},
"devDependencies": {
"@babel/generator": "^7.0.0-beta.46",
"acorn": "^5.5.3",
"babel-generator": "^6.26.1",
"babylon": "^7.0.0-beta.40",
"cherow": "^1.4.10",
"escodegen": "^1.9.1",
"eslint": "4.19.1",
"eslint-plugin-node": "6.0.1",
"eslint-plugin-prettier": "2.6.0",
"espree": "^3.5.4",
"esprima": "^4.0.0",
"flow-parser": "^0.70.0",
"prettier": "1.12.1",
"shift-parser": "^5.2.4",
"unexpected": "^10.37.5"
"@babel/generator": "7.1.6",
"@babel/parser": "7.1.6",
"acorn": "6.0.4",
"babel-generator": "6.26.1",
"cherow": "1.6.8",
"doctoc": "1.4.0",
"escodegen": "1.11.0",
"eslint": "5.9.0",
"eslint-config-lydell": "12.0.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jest": "22.1.0",
"eslint-plugin-prettier": "3.0.0",
"espree": "4.1.0",
"esprima": "4.0.1",
"flow-parser": "0.87.0",
"jest": "23.6.0",
"prettier": "1.15.3",
"rimraf": "2.6.2",
"shift-parser": "5.2.4",
"unexpected": "10.39.2"
}
}

@@ -1,2 +0,2 @@

# eslump
# eslump [![Build Status][travis-badge]][travis-link]

@@ -11,2 +11,24 @@ Fuzz testing JavaScript parsers and suchlike programs.

## Contents
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Installation](#installation)
- [CLI](#cli)
- [Module](#module)
- [`generateRandomJS(options = {})`](#generaterandomjsoptions--)
- [Disclaimer](#disclaimer)
- [Examples](#examples)
- [Test files](#test-files)
- [Development](#development)
- [npm scripts](#npm-scripts)
- [Directories](#directories)
- [License](#license)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- prettier-ignore-end -->
## Installation

@@ -16,15 +38,21 @@

`npm install --global eslump`
```
npm install --global eslump
```
You can also use parts of it as a Node.js module.
`npm install eslump`
```
npm install eslump
```
## Usage
## CLI
### CLI
<details>
<summary><code>eslump --help</code></summary>
```
Usage: eslump [options]
or: eslump TEST_MODULE OUTPUT_DIR [options]
or: eslump TEST_FILE OUTPUT_DIR [options]

@@ -42,3 +70,3 @@ Options:

When no arguments are provided, random JavaScript is printed to stdout.
Otherwise, TEST_MODULE is executed until an error occurs, or you kill the
Otherwise, TEST_FILE is executed until an error occurs, or you kill the
program. When an error occurs, the error is printed to stdout and files

@@ -49,11 +77,9 @@ are written to OUTPUT_DIR:

- random.backup.js is a backup of random.js.
- reproductionData.json contains additional data defined by TEST_MODULE
- reproductionData.json contains additional data defined by TEST_FILE
needed to reproduce the error caused by random.js, if any.
- Other files, if any, are defined by TEST_MODULE.
- Other files, if any, are defined by TEST_FILE.
OUTPUT_DIR is created as with `mkdir -p` if non-existent.
The value of TEST_MODULE is passed directly to the `require` function.
For information on how to write a TEST_MODULE, see:
For information on how to write a TEST_FILE, see:
https://github.com/lydell/eslump#test-files

@@ -66,4 +92,4 @@

# Run ./test.js and save the results in output/.
$ eslump ./test.js output/
# Run test.js and save the results in output/.
$ eslump test.js output/

@@ -75,11 +101,11 @@ # Narrow down the needed JavaScript to produce the error.

# Reproduce the narrowed down case.
$ eslump ./test.js output/ --reproduce
$ eslump test.js output/ --reproduce
```
### Module
</details>
### Overview
## Module
```js
const {generateRandomJS} = require("eslump");
const { generateRandomJS } = require("eslump");

@@ -94,3 +120,3 @@ const randomJSString = generateRandomJS({

#### generateRandomJS(options)
### `generateRandomJS(options = {})`

@@ -101,8 +127,8 @@ Returns a string of random JavaScript code.

Option | Type | Default | Description
-------|------|---------|------------
sourceType | `"module"` or `"script"` | `"module"` | The type of code to generate.
maxDepth | integer | 7 | How deeply nested AST:s to generate.
comments | boolean | false | Whether or not to generate random comments.
whitespace | boolean | false | Whether or not to generate random whitespace.
| Option | Type | Default | Description |
| ---------- | ------------------------ | ---------- | --------------------------------------------- |
| sourceType | `"module"` or `"script"` | `"module"` | The type of code to generate. |
| maxDepth | integer | 7 | How deeply nested AST:s to generate. |
| comments | boolean | false | Whether or not to generate random comments. |
| whitespace | boolean | false | Whether or not to generate random whitespace. |

@@ -124,10 +150,10 @@ ## Disclaimer

eslump has successfully found lots of little edge cases in Prettier, so it
evidently works. But there are no tests. (I’ve just gone meta and fuzz-tested it
using itself basically.)
evidently works. But there aren’t many tests. (I’ve mostly gone meta and
fuzz-tested it using itself basically.)
From the beginning eslump was only ever intended to be a CLI tool, but other
people have started to want to use eslump's code generation as an npm module, so
these days it can also be used as a module. If you know what you're doing.
people have started to want to use eslump’s code generation as an npm module, so
these days it can also be used as a module. If you know what you’re doing.
Here are some features I'd like to see from a proper random JS library:
Here are some features I’d like to see from a proper random JS library:

@@ -142,7 +168,8 @@ - No hacks.

There are several examples in the [examples](examples) directory.
There are several examples in the [examples] directory.
- Parsers:
- [acorn]
- [Babylon]
- [@babel/parser]
- [cherow]

@@ -160,7 +187,7 @@ - [espree]

To run the Babylon example, for instance, follow these steps:
To run the Acorn example, for instance, follow these steps:
1. Clone this repository.
2. `npm install` or (`yarn`)
3. `eslump ./examples/babylon.js output`
2. `npm ci`
3. `eslump examples/acorn.js output`

@@ -170,6 +197,6 @@ ## Test files

```
$ eslump ./test.js output/
$ eslump test.js output/
```
Test files, `./test.js` in the above example, must follow this pattern:
Test files, `test.js` in the above example, must follow this pattern:

@@ -180,3 +207,3 @@ ```js

sourceType, // String, either "module" or "script".
reproductionData = {} // undefined or anything that `JSON.parse` can return.
reproductionData = {}, // undefined or anything that `JSON.parse` can return.
}) => {

@@ -187,4 +214,4 @@ if (testFailedSomehow) {

reproductionData, // Optional. Anything that `JSON.stringify` can handle.
artifacts // Optional. Object mapping file names to string contents.
}
artifacts, // Optional. Object mapping file names to string contents.
};
}

@@ -259,2 +286,23 @@ // If the test passed, return nothing.

## Development
You need [Node.js] 10 and npm 6.
### npm scripts
- `npm run eslint`: Run [ESLint] \(including [Prettier]).
- `npm run eslint:fix`: Autofix [ESLint] errors.
- `npm run prettier`: Run [Prettier] for files other than JS.
- `npm run doctoc`: Run [doctoc] on README.md.
- `npm run jest`: Run unit tests. During development, `npm run jest -- --watch`
is nice, and `npm run jest -- --coverage` is interesting.
- `npm test`: Check that everything works.
- `npm publish`: Publish to [npm], but only if `npm test` passes.
### Directories
- `src/`: Source code.
- `examples/`: Examples, also used in tests.
- `test/`: [Jest] tests.
## License

@@ -264,15 +312,25 @@

<!-- prettier-ignore-start -->
[@babel/generator]: https://github.com/babel/babel/tree/master/packages/babel-generator
[@babel/parser]: https://babeljs.io/docs/en/next/babel-parser.html
[acorn]: https://github.com/ternjs/acorn
[@babel/generator]: https://github.com/babel/babel/tree/master/packages/babel-generator
[Babylon]: https://github.com/babel/babel/blob/master/packages/babylon
[cherow]: https://github.com/cherow/cherow
[doctoc]: https://github.com/thlorenz/doctoc/
[escodegen]: https://github.com/estools/escodegen
[esfuzz]: https://github.com/estools/esfuzz
[eslint]: https://eslint.org/
[espree]: https://github.com/eslint/espree
[esprima]: https://github.com/jquery/esprima
[examples]: https://github.com/lydell/eslump/tree/master/examples
[flow]: https://github.com/facebook/flow
[Prettier]: https://github.com/prettier/prettier/
[jest]: https://jestjs.io/
[node.js]: https://nodejs.org/en/
[npm]: https://www.npmjs.com/
[prettier]: https://github.com/prettier/prettier/
[shift-codegen]: https://github.com/shapesecurity/shift-codegen-js
[shift-fuzzer]: https://github.com/shapesecurity/shift-fuzzer-js
[shift-parser]: https://github.com/shapesecurity/shift-parser-js
[travis-badge]: https://travis-ci.com/lydell/eslump.svg?branch=master
[travis-link]: https://travis-ci.com/lydell/eslump
[typescript]: https://github.com/Microsoft/TypeScript
<!-- prettier-ignore-end -->
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