Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint + npm #410

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.json]
indent_size = 2

[*.yml]
indent_size = 2
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
lib

!.eslintrc.js
coverage

test/*/*.js

escodegen.browser.min.js
escodegen.browser.js
65 changes: 65 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';

module.exports = {
extends: 'eslint:recommended',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
env: {
node: true,
es6: true
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018
},
overrides: [{
files: '.eslintrc.js',
parserOptions: {
sourceType: 'script'
},
rules: {
strict: 'error'
}
}, {
files: 'test/**',
globals: {
expect: true
},
env: {
mocha: true
}
}],
rules: {
// 'push-with-multiple-arguments': 2,
/*
'no-unused-vars': [
2,
{
vars: 'all',
args: 'none'
}
],
*/
'no-unused-vars': 0,
'no-prototype-builtins': 0,
'new-cap': [
2,
{
capIsNew: false
}
],
semi: ['error'],
// indent: ['error', 4, { SwitchCase: 1 }],
'prefer-const': ['error'],
// 'no-var': ['error'],
// 'prefer-destructuring': ['error'],
// 'object-shorthand': ['error'],
// 'object-curly-spacing': ['error', 'always'],
// quotes: ['error', 'single'],
// 'quote-props': ['error', 'as-needed'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }]
// 'prefer-template': ['error']
}
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ node_modules/
cover_html/

npm-debug.log

escodegen.browser.min.js
escodegen.browser.js
15 changes: 0 additions & 15 deletions .npmignore

This file was deleted.

9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
sudo: false
language: node_js
script:
- npm run build
- npm test
node_js:
- "6"
- "8"
- "10"
- 10
- 12
- 14
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@ code generator from [Mozilla's Parser API](https://developer.mozilla.org/en/Spid
AST. See the [online generator](https://estools.github.io/escodegen/demo/index.html)
for a demo.


### Install

Escodegen can be used in a web browser:

<script src="escodegen.browser.js"></script>
```html
<script src="escodegen.browser.js"></script>
```

escodegen.browser.js can be found in tagged revisions on GitHub.

Or in a Node.js application via npm:

npm install escodegen
```sh
npm install escodegen
```

### Usage

A simple example: the program

escodegen.generate({
type: 'BinaryExpression',
operator: '+',
left: { type: 'Literal', value: 40 },
right: { type: 'Literal', value: 2 }
});
```js
escodegen.generate({
type: 'BinaryExpression',
operator: '+',
left: { type: 'Literal', value: 40 },
right: { type: 'Literal', value: 2 }
});
```

produces the string `'40 + 2'`.

Expand All @@ -45,13 +50,17 @@ options. To run the tests, execute `npm test` in the root directory.
At first, execute `npm install` to install the all dev dependencies.
After that,

npm run-script build
```sh
npm run-script build
```

will generate `escodegen.browser.js`, which can be used in browser environments.

And,

npm run-script build-min
```sh
npm run-script build-min
```

will generate the minified file `escodegen.browser.min.js`.

Expand Down
2 changes: 1 addition & 1 deletion benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ new Benchmark.Suite()
})

.on('start', function () {
console.log('Benchmarking...')
console.log('Benchmarking...');
})

.on('cycle', function (event) {
Expand Down
1 change: 0 additions & 1 deletion benchmark/old.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*global exports:true, require:true, global:true*/
(function () {
'use strict';

Expand Down
2 changes: 1 addition & 1 deletion bin/esgenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (files.length === 0) {

if (args.config) {
try {
options = JSON.parse(fs.readFileSync(args.config, 'utf-8'))
options = JSON.parse(fs.readFileSync(args.config, 'utf-8'));
} catch (err) {
console.error('Error parsing config: ', err);
}
Expand Down
1 change: 0 additions & 1 deletion escodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*global exports:true, require:true, global:true*/
(function () {
'use strict';

Expand Down
1 change: 1 addition & 0 deletions escodegen.js.map

Large diffs are not rendered by default.

84 changes: 0 additions & 84 deletions gulpfile.js

This file was deleted.