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/Rollup #110

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc → .babelrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": [["env", {
"presets": [["@babel/preset-env", {
"targets": {
"node": "4.0"
}
Expand Down
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
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist

!.eslintrc.js
coverage
48 changes: 48 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true
},
extends: 'eslint:recommended',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
overrides: [{
files: '.eslintrc.js',
parserOptions: {
sourceType: 'script'
},
rules: {
strict: 'error'
}
}, {
files: 'test/**',
globals: {
expect: true
},
env: {
mocha: true
}
}],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018
},
rules: {
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']
}
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ coverage/

npm-debug.log
.vimrc.local

dist
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

16 changes: 0 additions & 16 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = false
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ arch:
- ppc64le
language: node_js
node_js:
- 4
- 6
- 8
- 12
- 14
- 16
- 17
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ The following code will output all variables declared at the root of a file.

```javascript
estraverse.traverse(ast, {
enter: function (node, parent) {
enter (node, parent) {
if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
return estraverse.VisitorOption.Skip;
},
leave: function (node, parent) {
leave (node, parent) {
if (node.type == 'VariableDeclarator')
console.log(node.id.name);
}
Expand All @@ -29,7 +29,7 @@ We can use `this.skip`, `this.remove` and `this.break` functions instead of usin

```javascript
estraverse.traverse(ast, {
enter: function (node) {
enter (node) {
this.break();
}
});
Expand All @@ -38,8 +38,8 @@ estraverse.traverse(ast, {
And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.

```javascript
result = estraverse.replace(tree, {
enter: function (node) {
const result = estraverse.replace(tree, {
enter (node) {
// Replace it with replaced.
if (node.type === 'Literal')
return replaced;
Expand All @@ -51,7 +51,7 @@ By passing `visitor.keys` mapping, we can extend estraverse traversing functiona

```javascript
// This tree contains a user-defined `TestExpression` node.
var tree = {
const tree = {
type: 'TestExpression',

// This 'argument' is the property containing the other **node**.
Expand All @@ -64,7 +64,7 @@ var tree = {
extended: true
};
estraverse.traverse(tree, {
enter: function (node) { },
enter (node) { },

// Extending the existing traversing rules.
keys: {
Expand All @@ -78,7 +78,7 @@ By passing `visitor.fallback` option, we can control the behavior when encounter

```javascript
// This tree contains a user-defined `TestExpression` node.
var tree = {
const tree = {
type: 'TestExpression',

// This 'argument' is the property containing the other **node**.
Expand All @@ -91,7 +91,7 @@ var tree = {
extended: true
};
estraverse.traverse(tree, {
enter: function (node) { },
enter (node) { },

// Iterating the child **nodes** of unknown nodes.
fallback: 'iteration'
Expand All @@ -102,7 +102,7 @@ When `visitor.fallback` is a function, we can determine which keys to visit on e

```javascript
// This tree contains a user-defined `TestExpression` node.
var tree = {
const tree = {
type: 'TestExpression',

// This 'argument' is the property containing the other **node**.
Expand All @@ -115,11 +115,11 @@ var tree = {
extended: true
};
estraverse.traverse(tree, {
enter: function (node) { },
enter (node) { },

// Skip the `argument` property of each node
fallback: function(node) {
return Object.keys(node).filter(function(key) {
fallback(node) {
return Object.keys(node).filter((key) => {
return key !== 'argument';
});
}
Expand Down
70 changes: 0 additions & 70 deletions gulpfile.js

This file was deleted.

72 changes: 51 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,69 @@
"name": "estraverse",
"description": "ECMAScript JS AST traversal functions",
"homepage": "https://github.com/estools/estraverse",
"main": "estraverse.js",
"bugs": "https://github.com/estools/estraverse/issues",
"type": "module",
"main": "./dist/estraverse.min.js",
"exports": {
"import": "./dist/estraverse.esm.min.js",
"require": "./dist/estraverse.min.js"
},
"version": "5.3.0",
"engines": {
"node": ">=4.0"
},
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
}
"keywords": [
"traversal"
],
"author": {
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
},
"contributors": [
"Brett Zamir"
],
"files": [
"estraverse.js",
"dist"
],
"repository": {
"type": "git",
"url": "http://github.com/estools/estraverse.git"
},
"dependencies": {},
"devDependencies": {
"babel-preset-env": "^1.6.1",
"babel-register": "^6.3.13",
"chai": "^2.1.1",
"espree": "^1.11.0",
"gulp": "^3.8.10",
"gulp-bump": "^0.2.2",
"gulp-filter": "^2.0.0",
"gulp-git": "^1.0.1",
"gulp-tag-version": "^1.3.0",
"jshint": "^2.5.6",
"mocha": "^2.1.0"
"@babel/core": "^7.17.5",
"@babel/preset-env": "^7.16.11",
"@babel/register": "^7.17.0",
"@rollup/plugin-babel": "^5.3.1",
"c8": "^7.11.0",
"chai": "^4.3.6",
"eslint": "^8.10.0",
"espree": "^9.3.1",
"esprima": "^4.0.1",
"mocha": "^9.2.1",
"rollup": "^2.70.0",
"rollup-plugin-terser": "^7.0.2"
},
"license": "BSD-2-Clause",
"c8": {
"branches": 100,
"lines": 100,
"functions": 100,
"statements": 100,
"reporter": [
"html",
"text"
],
"exclude": [
"test"
]
},
"scripts": {
"test": "npm run-script lint && npm run-script unit-test",
"lint": "jshint estraverse.js",
"unit-test": "mocha --compilers js:babel-register"
"build": "rollup -c",
"test": "npm run lint && npm run unit-test",
"lint": "eslint .",
"unit-test": "c8 mocha --require chai/register-expect.js --require @babel/register"
}
}
Loading