Skip to content

Commit 41e5281

Browse files
committed
chore: lint
1 parent 300ac78 commit 41e5281

10 files changed

+120
-94
lines changed

.eslintrc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"node/no-unsupported-features/node-builtins": "off"
77
},
88
"extends": [
9-
"plugin:node/recommended",
9+
"plugin:n/recommended",
1010
"plugin:putout/recommended"
1111
],
1212
"plugins": [
1313
"putout",
14-
"node"
14+
"n"
1515
]
1616
}

.github/workflows/nodejs.yml

+30-38
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
11
name: Node CI
2-
3-
on: [push, pull_request]
4-
2+
on:
3+
- push
4+
- pull_request
55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
9-
108
strategy:
119
matrix:
12-
node-version: [14.x, 15.x]
13-
10+
node-version:
11+
- 18.x
12+
- 20.x
13+
- 21.x
1414
steps:
15-
- uses: actions/checkout@v1
16-
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
21-
- name: Install Redrun
22-
run:
23-
npm i redrun -g
24-
25-
- name: Install
26-
run:
27-
npm install
28-
29-
- name: Bootstrap
30-
run:
31-
redrun bootstrap
32-
33-
- name: Lint
34-
run:
35-
redrun lint
36-
37-
- name: Coverage
38-
run:
39-
redrun coverage report
40-
41-
- name: Coveralls
42-
uses: coverallsapp/github-action@master
43-
with:
44-
github-token: ${{ secrets.GITHUB_TOKEN }}
45-
15+
- uses: actions/checkout@v4
16+
- uses: oven-sh/setup-bun@v1
17+
with:
18+
bun-version: latest
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: Install Redrun
24+
run: bun i redrun -g --no-save
25+
- name: Install
26+
run: bun i --no-save
27+
- name: Bootstrap
28+
run: redrun bootstrap
29+
- name: Lint
30+
run: redrun lint
31+
- name: Coverage
32+
run: redrun coverage report
33+
- name: Coveralls
34+
uses: coverallsapp/github-action@v2
35+
continue-on-error: true
36+
with:
37+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ yarn-error.log
77
.nyc_output
88
*.swp
99

10+
.idea

.madrun.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ export default {
1212
'watch:test': () => run('watcher', 'npm test'),
1313
'watcher': () => 'nodemon -w test -w lib --exec',
1414
};
15-

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
1+
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
22

33
[NPMIMGURL]: https://img.shields.io/npm/v/readify.svg?style=flat
44
[BuildStatusURL]: https://github.com/coderaiser/readify/actions?query=workflow%3A%22Node+CI%22 "Build Status"
55
[BuildStatusIMGURL]: https://github.com/coderaiser/readify/workflows/Node%20CI/badge.svg
6-
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/readify.svg?style=flat
76
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
87
[NPMURL]: https://npmjs.org/package/readify "npm"
9-
[DependencyStatusURL]: https://david-dm.org/coderaiser/readify "Dependency Status"
108
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
119
[CoverageURL]: https://coveralls.io/github/coderaiser/readify?branch=master
1210
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/readify/badge.svg?branch=master&service=github
@@ -52,7 +50,9 @@ console.log(data);
5250
}],
5351
});
5452

55-
readify('/', {type: 'raw'}).then(console.log);
53+
readify('/', {
54+
type: 'raw',
55+
}).then(console.log);
5656
// output
5757
({
5858
path: '/',
@@ -66,7 +66,11 @@ readify('/', {type: 'raw'}).then(console.log);
6666
}],
6767
});
6868

69-
readify('/', {type: 'raw', sort: 'size', order: 'desc'}).then(console.log);
69+
readify('/', {
70+
type: 'raw',
71+
sort: 'size',
72+
order: 'desc',
73+
}).then(console.log);
7074
// output
7175
({
7276
path: '/',

lib/readdir.js

-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,3 @@ function getType({name, isDir, isLink}) {
7373

7474
return `${type}${link}`;
7575
}
76-

lib/readify.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const process = require('node:process');
4+
const isUndefined = (a) => typeof a === 'undefined';
35
const format = require('format-io');
46
const currify = require('currify');
57
const tryToCatch = require('try-to-catch');
@@ -9,12 +11,10 @@ const formatify = require('@cloudcmd/formatify');
911

1012
const WIN = process.platform === 'win32';
1113

12-
const ifRaw = currify(_ifRaw);
13-
const replaceProperty = currify(_replaceProperty);
14-
15-
const nicki = !WIN && require('nicki');
16-
1714
const readdir = require('./readdir');
15+
const nicki = !WIN && require('nicki');
16+
const replaceProperty = currify(_replaceProperty);
17+
const ifRaw = currify(_ifRaw);
1818
const isString = (a) => typeof a === 'string';
1919

2020
module.exports = readify;
@@ -97,12 +97,11 @@ function _replaceProperty(obj, prop, item) {
9797
const n = item[prop];
9898
const data = obj[n];
9999

100-
if (typeof data === 'undefined')
100+
if (isUndefined(data))
101101
return item;
102102

103103
return {
104104
...item,
105105
[prop]: data,
106106
};
107107
}
108-

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "readify",
33
"version": "9.0.0",
4+
"type": "commonjs",
45
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
56
"description": "Read directory content with file attributes: size, date, owner, mode",
67
"homepage": "http://github.com/coderaiser/readify",

test/readdir.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
const fs = require('fs');
44

5-
const stub = require('@cloudcmd/stub');
6-
const test = require('supertape');
5+
const {test, stub} = require('supertape');
76
const mockRequire = require('mock-require');
8-
const {reRequire, stopAll} = mockRequire;
9-
const tryToCatch = require('try-to-catch');
107

8+
const tryToCatch = require('try-to-catch');
9+
const {reRequire, stopAll} = mockRequire;
1110
const noop = () => {};
1211

1312
test('readdir: empty dir', async (t) => {
1413
const {readdir} = fs.promises;
14+
1515
fs.promises.readdir = async () => [];
1616

1717
const _readdir = reRequire('../lib/readdir');
@@ -31,9 +31,7 @@ test('readdir: empty stat', async (t) => {
3131
throw Error('some');
3232
});
3333

34-
fs.promises.readdir = async () => [
35-
'hello',
36-
];
34+
fs.promises.readdir = async () => ['hello'];
3735

3836
const _readdir = reRequire('../lib/readdir');
3937

@@ -245,4 +243,3 @@ test('readdir: result: directory link: no error', async (t) => {
245243
t.notOk(e, e?.message || 'should not receive error');
246244
t.end();
247245
});
248-

0 commit comments

Comments
 (0)