Skip to content

Commit 8157783

Browse files
committed
build: prettify and lint staged files
1 parent 09855f5 commit 8157783

12 files changed

Lines changed: 175 additions & 142 deletions

File tree

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run lint:staged

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
"cz-conventional-changelog": "^3.3.0",
77
"glob": "^11.0.0",
88
"husky": "^9.1.5",
9-
"lerna": "^8.1.8"
9+
"lerna": "^8.1.8",
10+
"lint-staged": "^15.2.9"
11+
},
12+
"lint-staged": {
13+
"*.js": "npm run lint:fix",
14+
"*.md": "prettier -w"
1015
},
1116
"repository": {
1217
"type": "git",
@@ -18,7 +23,8 @@
1823
"publish": "lerna publish from-git --yes",
1924
"lint:check": "lerna run lint:check",
2025
"lint:fix": "lerna run lint:fix",
21-
"pretest": "npm run lint",
26+
"lint:staged": "npx lint-staged",
27+
"pretest": "npm run build",
2228
"test": "lerna run test",
2329
"test:legacy": "lerna run test:legacy",
2430
"version": "lerna version"

packages/csv-generate/README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# CSV generator for Node.js and the web
32

43
[![Build Status](https://img.shields.io/github/actions/workflow/status/adaltas/node-csv/nodejs.yml?branch=master)](https://github.com/adaltas/node-csv/actions)
@@ -9,19 +8,19 @@ The [`csv-generate` package](https://csv.js.org/generate/) provides a flexible g
98

109
## Documentation
1110

12-
* [Project homepage](https://csv.js.org/generate/)
13-
* [API](https://csv.js.org/generate/api/)
14-
* [Options](https://csv.js.org/generate/options/)
15-
* [Examples](https://csv.js.org/generate/examples/)
11+
- [Project homepage](https://csv.js.org/generate/)
12+
- [API](https://csv.js.org/generate/api/)
13+
- [Options](https://csv.js.org/generate/options/)
14+
- [Examples](https://csv.js.org/generate/examples/)
1615

1716
## Main features
1817

19-
* Scalable `stream.Readable` implementation
20-
* random or pseudo-random seed based generation
21-
* Idempotence with the "seed" option
22-
* User-defined value generation
23-
* Multiple types of values (integer, boolean, dates, ...)
24-
* MIT License
18+
- Scalable `stream.Readable` implementation
19+
- random or pseudo-random seed based generation
20+
- Idempotence with the "seed" option
21+
- User-defined value generation
22+
- Multiple types of values (integer, boolean, dates, ...)
23+
- MIT License
2524

2625
## Usage
2726

@@ -34,39 +33,40 @@ Use the callback and sync APIs for simplicity or the stream based API for scalab
3433
The [API](https://csv.js.org/generate/api/) is available in multiple flavors. This example illustrates the stream API.
3534

3635
```js
37-
import { generate } from 'csv-generate';
38-
import assert from 'assert';
36+
import { generate } from "csv-generate";
37+
import assert from "assert";
3938

4039
const records = [];
4140
// Initialize the generator
4241
generate({
4342
seed: 1,
4443
objectMode: true,
4544
columns: 2,
46-
length: 2
45+
length: 2,
4746
})
4847
// Use the readable stream api to consume generated records
49-
.on('readable', function(){
50-
let record; while((record = this.read()) !== null){
48+
.on("readable", function () {
49+
let record;
50+
while ((record = this.read()) !== null) {
5151
records.push(record);
5252
}
5353
})
5454
// Catch any error
55-
.on('error', function(err){
55+
.on("error", function (err) {
5656
console.error(err);
5757
})
5858
// Test that the generated records matched the expected records
59-
.on('end', function(){
59+
.on("end", function () {
6060
assert.deepEqual(records, [
61-
[ 'OMH', 'ONKCHhJmjadoA' ],
62-
[ 'D', 'GeACHiN' ]
61+
["OMH", "ONKCHhJmjadoA"],
62+
["D", "GeACHiN"],
6363
]);
6464
});
6565
```
6666

6767
## Development
6868

69-
Tests are executed with [Mocha](https://mochajs.org/). To install it, simple run `npm install` followed by `npm test`. It will install mocha and its dependencies in your project "node_modules" directory and run the test suite. The tests run against the CoffeeScript source files.
69+
Tests are executed with [Mocha](https://mochajs.org/). To install it, simple run `npm install` followed by `npm test`. It will install mocha and its dependencies in your project "node_modules" directory and run the test suite. The tests run against the CoffeeScript source files.
7070

7171
To generate the JavaScript files, run `npm run coffee`.
7272

@@ -76,4 +76,4 @@ The test suite is run online with [Travis](https://travis-ci.org/#!/adaltas/node
7676

7777
The project is sponsored by [Adaltas](https://www.adaltas.com), an Big Data consulting firm based in Paris, France.
7878

79-
* David Worms: <https://github.com/wdavidw>
79+
- David Worms: <https://github.com/wdavidw>

packages/csv-generate/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
"throw-deprecation": false,
9191
"timeout": 40000
9292
},
93+
"lint-staged": {
94+
"*.js": "npm run lint:fix",
95+
"*.md": "prettier -w"
96+
},
9397
"repository": {
9498
"type": "git",
9599
"url": "https://github.com/adaltas/node-csv.git",
@@ -100,8 +104,9 @@
100104
"build:rollup": "npx rollup -c",
101105
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/stream.d.ts dist/cjs/stream.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
102106
"postbuild:ts": "find dist/cjs -name '*.d.cts' -exec sh -c \"sed -i \"s/\\.js'/\\.cjs'/g\" {} || sed -i '' \"s/\\.js'/\\.cjs'/g\" {}\" \\;",
103-
"lint:check": "eslint && tsc --noEmit true",
104-
"lint:fix": "eslint --fix && tsc --noEmit true",
107+
"lint:check": "eslint",
108+
"lint:fix": "eslint --fix",
109+
"lint:ts": "tsc --noEmit true",
105110
"preversion": "npm run build && git add dist",
106111
"pretest": "npm run build",
107112
"test": "mocha 'test/**/*.{coffee,ts}'",

packages/csv-parse/README.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
21
# CSV parser for Node.js and the web
32

43
[![Build Status](https://img.shields.io/github/actions/workflow/status/adaltas/node-csv/nodejs.yml?branch=master)](https://github.com/adaltas/node-csv/actions)
54
[![NPM](https://img.shields.io/npm/dm/csv-parse)](https://www.npmjs.com/package/csv-parse)
65
[![NPM](https://img.shields.io/npm/v/csv-parse)](https://www.npmjs.com/package/csv-parse)
7-
6+
87
The [`csv-parse` package](https://csv.js.org/parse/) is a parser converting CSV text input into arrays or objects. It is part of the [CSV project](https://csv.js.org/).
98

109
It implements the Node.js [`stream.Transform` API](http://nodejs.org/api/stream.html#stream_class_stream_transform). It also provides a simple callback-based API for convenience. It is both extremely easy to use and powerful. It was first released in 2010 and is used against big data sets by a large community.
1110

1211
## Documentation
1312

14-
* [Project homepage](https://csv.js.org/parse/)
15-
* [API](https://csv.js.org/parse/api/)
16-
* [Options](https://csv.js.org/parse/options/)
17-
* [Info properties](https://csv.js.org/parse/info/)
18-
* [Common errors](https://csv.js.org/parse/errors/)
19-
* [Examples](https://csv.js.org/project/examples/)
13+
- [Project homepage](https://csv.js.org/parse/)
14+
- [API](https://csv.js.org/parse/api/)
15+
- [Options](https://csv.js.org/parse/options/)
16+
- [Info properties](https://csv.js.org/parse/info/)
17+
- [Common errors](https://csv.js.org/parse/errors/)
18+
- [Examples](https://csv.js.org/project/examples/)
2019

2120
## Main features
2221

23-
* Flexible with lot of [options](https://csv.js.org/parse/options/)
24-
* Multiple [distributions](https://csv.js.org/parse/distributions/): Node.js, Web, ECMAScript modules and CommonJS
25-
* Follow the Node.js streaming API
26-
* Simplicity with the optional callback API
27-
* Support delimiters, quotes, escape characters and comments
28-
* Line breaks discovery
29-
* Support big datasets
30-
* Complete test coverage and lot of samples for inspiration
31-
* No external dependencies
32-
* Work nicely with the [csv-generate](https://csv.js.org/generate/), [stream-transform](https://csv.js.org/transform/) and [csv-stringify](https://csv.js.org/stringify/) packages
33-
* MIT License
22+
- Flexible with lot of [options](https://csv.js.org/parse/options/)
23+
- Multiple [distributions](https://csv.js.org/parse/distributions/): Node.js, Web, ECMAScript modules and CommonJS
24+
- Follow the Node.js streaming API
25+
- Simplicity with the optional callback API
26+
- Support delimiters, quotes, escape characters and comments
27+
- Line breaks discovery
28+
- Support big datasets
29+
- Complete test coverage and lot of samples for inspiration
30+
- No external dependencies
31+
- Work nicely with the [csv-generate](https://csv.js.org/generate/), [stream-transform](https://csv.js.org/transform/) and [csv-stringify](https://csv.js.org/stringify/) packages
32+
- MIT License
3433

3534
## Usage
3635

@@ -43,34 +42,31 @@ Use the callback and sync APIs for simplicity or the stream based API for scalab
4342
The [API](https://csv.js.org/parse/api/) is available in multiple flavors. This example illustrates the stream API.
4443

4544
```js
46-
import assert from 'assert';
47-
import { parse } from 'csv-parse';
45+
import assert from "assert";
46+
import { parse } from "csv-parse";
4847

4948
const records = [];
5049
// Initialize the parser
5150
const parser = parse({
52-
delimiter: ':'
51+
delimiter: ":",
5352
});
5453
// Use the readable stream api to consume records
55-
parser.on('readable', function(){
54+
parser.on("readable", function () {
5655
let record;
5756
while ((record = parser.read()) !== null) {
5857
records.push(record);
5958
}
6059
});
6160
// Catch any error
62-
parser.on('error', function(err){
61+
parser.on("error", function (err) {
6362
console.error(err.message);
6463
});
6564
// Test that the parsed records matched the expected records
66-
parser.on('end', function(){
67-
assert.deepStrictEqual(
68-
records,
69-
[
70-
[ 'root','x','0','0','root','/root','/bin/bash' ],
71-
[ 'someone','x','1022','1022','','/home/someone','/bin/bash' ]
72-
]
73-
);
65+
parser.on("end", function () {
66+
assert.deepStrictEqual(records, [
67+
["root", "x", "0", "0", "root", "/root", "/bin/bash"],
68+
["someone", "x", "1022", "1022", "", "/home/someone", "/bin/bash"],
69+
]);
7470
});
7571
// Write data to the stream
7672
parser.write("root:x:0:0:root:/root:/bin/bash\n");
@@ -83,4 +79,4 @@ parser.end();
8379

8480
The project is sponsored by [Adaltas](https://www.adaltas.com), an Big Data consulting firm based in Paris, France.
8581

86-
* David Worms: <https://github.com/wdavidw>
82+
- David Worms: <https://github.com/wdavidw>

packages/csv-parse/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@
103103
"throw-deprecation": false,
104104
"timeout": 40000
105105
},
106+
"lint-staged": {
107+
"*.js": "npm run lint:fix",
108+
"*.md": "prettier -w"
109+
},
106110
"repository": {
107111
"type": "git",
108112
"url": "https://github.com/adaltas/node-csv.git",
@@ -113,8 +117,9 @@
113117
"build:rollup": "npx rollup -c",
114118
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
115119
"postbuild:ts": "find dist/cjs -name '*.d.cts' -exec sh -c \"sed -i \"s/\\.js'/\\.cjs'/g\" {} || sed -i '' \"s/\\.js'/\\.cjs'/g\" {}\" \\;",
116-
"lint:check": "eslint && tsc --noEmit true",
117-
"lint:fix": "eslint --fix && tsc --noEmit true",
120+
"lint:check": "eslint",
121+
"lint:fix": "eslint --fix",
122+
"lint:ts": "tsc --noEmit true",
118123
"preversion": "npm run build && git add dist",
119124
"pretest": "npm run build",
120125
"test": "mocha 'test/**/*.{coffee,ts}'",

packages/csv-stringify/README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# CSV stringifier for Node.js and the web
32

43
[![Build Status](https://img.shields.io/github/actions/workflow/status/adaltas/node-csv/nodejs.yml?branch=master)](https://github.com/adaltas/node-csv/actions)
@@ -9,21 +8,21 @@ The [`csv-stringify` package](https://csv.js.org/stringify/) is a stringifier co
98

109
## Documentation
1110

12-
* [Project homepage](https://csv.js.org/stringify/)
13-
* [API](https://csv.js.org/stringify/api/)
14-
* [Options](https://csv.js.org/stringify/options/)
15-
* [Examples](https://csv.js.org/stringify/examples/)
11+
- [Project homepage](https://csv.js.org/stringify/)
12+
- [API](https://csv.js.org/stringify/api/)
13+
- [Options](https://csv.js.org/stringify/options/)
14+
- [Examples](https://csv.js.org/stringify/examples/)
1615

1716
## Main features
1817

19-
* Follow the Node.js streaming API
20-
* Simplicity with the optional callback API
21-
* Support for custom formatters, delimiters, quotes, escape characters and header
22-
* Support big datasets
23-
* Complete test coverage and samples for inspiration
24-
* Only 1 external dependency
25-
* to be used conjointly with `csv-generate`, `csv-parse` and `stream-transform`
26-
* MIT License
18+
- Follow the Node.js streaming API
19+
- Simplicity with the optional callback API
20+
- Support for custom formatters, delimiters, quotes, escape characters and header
21+
- Support big datasets
22+
- Complete test coverage and samples for inspiration
23+
- Only 1 external dependency
24+
- to be used conjointly with `csv-generate`, `csv-parse` and `stream-transform`
25+
- MIT License
2726

2827
## Usage
2928

@@ -36,15 +35,15 @@ The module is built on the Node.js Stream API. Use the callback and sync APIs fo
3635
The [API](https://csv.js.org/stringify/api/) is available in multiple flavors. This example illustrates the sync API.
3736

3837
```js
39-
import { stringify } from 'csv-stringify/sync';
40-
import assert from 'assert';
38+
import { stringify } from "csv-stringify/sync";
39+
import assert from "assert";
4140

4241
const output = stringify([
43-
[ '1', '2', '3', '4' ],
44-
[ 'a', 'b', 'c', 'd' ]
42+
["1", "2", "3", "4"],
43+
["a", "b", "c", "d"],
4544
]);
4645

47-
assert.equal(output, '1,2,3,4\na,b,c,d\n');
46+
assert.equal(output, "1,2,3,4\na,b,c,d\n");
4847
```
4948

5049
## Development
@@ -59,4 +58,4 @@ The test suite is run online with [Travis](https://travis-ci.org/#!/adaltas/node
5958

6059
The project is sponsored by [Adaltas](https://www.adaltas.com), an Big Data consulting firm based in Paris, France.
6160

62-
* David Worms: <https://github.com/wdavidw>
61+
- David Worms: <https://github.com/wdavidw>

packages/csv-stringify/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
"throw-deprecation": false,
8181
"timeout": 40000
8282
},
83+
"lint-staged": {
84+
"*.js": "npm run lint:fix",
85+
"*.md": "prettier -w"
86+
},
8387
"repository": {
8488
"type": "git",
8589
"url": "https://github.com/adaltas/node-csv.git",
@@ -90,8 +94,9 @@
9094
"build:rollup": "npx rollup -c",
9195
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
9296
"postbuild:ts": "find dist/cjs -name '*.d.cts' -exec sh -c \"sed -i \"s/\\.js'/\\.cjs'/g\" {} || sed -i '' \"s/\\.js'/\\.cjs'/g\" {}\" \\;",
93-
"lint:check": "eslint && tsc --noEmit true",
94-
"lint:fix": "eslint --fix && tsc --noEmit true",
97+
"lint:check": "eslint",
98+
"lint:fix": "eslint --fix",
99+
"lint:ts": "tsc --noEmit true",
95100
"preversion": "npm run build && git add dist",
96101
"pretest": "npm run build",
97102
"test": "mocha 'test/**/*.{coffee,ts}'",

0 commit comments

Comments
 (0)