Skip to content

Commit 59cd454

Browse files
authored
chore: use neostandard (#116)
* chore: use neostandard Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> * ci: update workflow Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> * improve ci Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> * fix npm support Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> * fix support Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> --------- Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
1 parent 7201845 commit 59cd454

5 files changed

Lines changed: 70 additions & 43 deletions

File tree

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
name: ci
22

33
on:
4-
- pull_request
5-
- push
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
permissions:
12+
contents: read
13+
14+
# Cancel in progress workflows
15+
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
16+
concurrency:
17+
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
18+
cancel-in-progress: true
619

720
jobs:
21+
lint:
22+
name: Lint
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 'lts/*'
32+
33+
- name: Install dependencies
34+
run: npm install --ignore-scripts --include=dev
35+
36+
- name: Run lint
37+
run: npm run lint
38+
839
test:
940
runs-on: ubuntu-latest
1041
strategy:
42+
fail-fast: false
1143
matrix:
1244
name:
1345
- Node.js 0.10
@@ -70,11 +102,13 @@ jobs:
70102

71103
- name: Node.js 6.x
72104
node-version: "6.17"
73-
npm-i: mocha@6.2.2 nyc@14.1.1
105+
npm-version: "npm@3.8.6"
106+
npm-i: mocha@5.2.0 nyc@11.9.0
74107

75108
- name: Node.js 7.x
76109
node-version: "7.10"
77-
npm-i: mocha@6.2.2 nyc@14.1.1
110+
npm-version: "npm@3.8.6"
111+
npm-i: mocha@5.2.0 nyc@11.9.0
78112

79113
- name: Node.js 8.0
80114
node-version: "8.0"
@@ -153,6 +187,10 @@ jobs:
153187
nvm install --default ${{ matrix.node-version }}
154188
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
155189
190+
- name: Npm version fixes
191+
if: ${{matrix.npm-version != ''}}
192+
run: npm install -g ${{ matrix.npm-version }}
193+
156194
- name: Configure npm
157195
run: |
158196
if [[ "$(npm config get package-lock)" == "true" ]]; then
@@ -161,22 +199,13 @@ jobs:
161199
npm config set shrinkwrap false
162200
fi
163201
202+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
203+
run: npm rm --silent --save-dev neostandard @stylistic/eslint-plugin-js @stylistic/eslint-plugin eslint
204+
164205
- name: Install npm module(s) ${{ matrix.npm-i }}
165206
run: npm install --save-dev ${{ matrix.npm-i }}
166207
if: matrix.npm-i != ''
167208

168-
- name: Setup Node.js version-specific dependencies
169-
shell: bash
170-
run: |
171-
# eslint for linting
172-
# - remove on Node.js < 12
173-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
174-
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
175-
grep -E '^eslint(-|$)' | \
176-
sort -r | \
177-
xargs -n1 npm rm --silent --save-dev
178-
fi
179-
180209
- name: Install Node.js dependencies
181210
run: npm install
182211

@@ -193,16 +222,12 @@ jobs:
193222
shell: bash
194223
run: |
195224
if npm -ps ls nyc | grep -q nyc; then
196-
npm run test-ci
225+
npm run test:ci
197226
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
198227
else
199228
npm test
200229
fi
201230
202-
- name: Lint code
203-
if: steps.list_env.outputs.eslint != ''
204-
run: npm run lint
205-
206231
- name: Upload code coverage
207232
uses: actions/upload-artifact@v5
208233
with:

eslint.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict'
2+
const neostandard = require('neostandard')
3+
4+
module.exports = [
5+
...neostandard({
6+
env: ['mocha'],
7+
}),
8+
{
9+
rules: {
10+
'object-shorthand': ['off'], // Compatibility with older code
11+
'no-var': ['off'], // Compatibility with older code
12+
'no-redeclare': ['off'], // Because we use var for compatibility with node 0.10
13+
}
14+
}
15+
]

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
"unpipe": "1.0.0"
1717
},
1818
"devDependencies": {
19+
"@stylistic/eslint-plugin": "^5.1.0",
20+
"@stylistic/eslint-plugin-js": "^4.1.0",
1921
"bluebird": "3.7.2",
20-
"eslint": "8.57.0",
21-
"eslint-config-standard": "15.0.1",
22-
"eslint-plugin-import": "2.29.1",
23-
"eslint-plugin-markdown": "3.0.0",
24-
"eslint-plugin-node": "11.1.0",
25-
"eslint-plugin-promise": "6.6.0",
26-
"eslint-plugin-standard": "4.1.0",
22+
"eslint": "^9.0.0",
2723
"mocha": "10.7.0",
24+
"neostandard": "^0.12.0",
2825
"nyc": "17.0.0",
2926
"readable-stream": "2.3.7",
3027
"safe-buffer": "5.2.1"
@@ -41,10 +38,11 @@
4138
"index.js"
4239
],
4340
"scripts": {
44-
"lint": "eslint .",
45-
"test": "mocha --trace-deprecation --reporter spec --bail --check-leaks test/",
46-
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
47-
"test-cov": "nyc --reporter=html --reporter=text npm test",
41+
"lint": "eslint",
42+
"lint:fix": "eslint --fix",
43+
"test": "mocha --trace-deprecation --reporter spec --check-leaks test/",
44+
"test:ci": "nyc --reporter=lcovonly --reporter=text npm test",
45+
"test:cov": "nyc --reporter=html --reporter=text npm test",
4846
"version": "node scripts/version-history.js && git add HISTORY.md"
4947
}
5048
}

0 commit comments

Comments
 (0)