Skip to content

Commit

Permalink
Merge pull request #29 from XhmikosR/dev-1
Browse files Browse the repository at this point in the history
Assorted tweaks
  • Loading branch information
mrjoelkemp authored Feb 19, 2022
2 parents 87c4f33 + 65e402e commit e7010cb
Show file tree
Hide file tree
Showing 14 changed files with 4,274 additions and 35 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"rules": {
"strict": "error"
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce Unix newlines
* text=auto eol=lf
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

env:
FORCE_COLOR: 2

jobs:
test:
name: Node ${{ matrix.node }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node: [6, 8, 10, 12, 14, 16]

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: npm

# TODO: drop this later
- name: Install npm dependencies
run: npm install
if: matrix.node == 6

- name: Install npm dependencies
run: npm ci
if: matrix.node != 6

- name: Run tests
run: npm test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
/node_modules/
3 changes: 0 additions & 3 deletions .jscsrc

This file was deleted.

7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"check-leaks": true,
"throw-deprecation": true,
"trace-deprecation": true,
"trace-warnings": true,
"use_strict": true
}
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### node-source-walk [![npm](http://img.shields.io/npm/v/node-source-walk.svg)](https://npmjs.org/package/node-source-walk) [![npm](http://img.shields.io/npm/dm/node-source-walk.svg)](https://npmjs.org/package/node-source-walk)
### node-source-walk [![CI](https://github.com/dependents/node-source-walk/actions/workflows/ci.yml/badge.svg)](https://github.com/dependents/node-source-walk/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/node-source-walk)](https://www.npmjs.com/package/node-source-walk) [![npm](https://img.shields.io/npm/dm/node-source-walk)](https://www.npmjs.com/package/node-source-walk)

> Synchronously execute a callback on every node of a file's AST and stop walking whenever you see fit.
Expand All @@ -23,7 +23,7 @@

```

By default, Walker will use `babylon` (supporting ES6, JSX, Flow, and all other available babylon plugins) and the `sourceType: module`, but you can change any of the defaults as follows:
By default, Walker will use `@babel/parser` (supporting ES6, JSX, Flow, and all other available @babel/parser plugins) and the `sourceType: module`, but you can change any of the defaults as follows:

```js
var walker = new Walker({
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const parser = require('@babel/parser');

/**
Expand Down Expand Up @@ -77,7 +79,10 @@ module.exports.prototype.traverse = function(node, cb) {
// Avoid visited nodes
if (key === 'parent' || !node[key]) { continue; }

node[key].parent = node;
if (typeof node[key] === 'object') {
node[key].parent = node;
}

this.traverse(node[key], cb);
}
}
Expand Down
Loading

0 comments on commit e7010cb

Please sign in to comment.