Skip to content

Commit 1a1e18e

Browse files
authored
chore: apply prettier & setup ci workflow (#857)
* refactor: apply prettier to the entire codebase * ci: setup workflow to ensure files are formatted with prettier
1 parent 4e5c8f2 commit 1a1e18e

31 files changed

+249
-245
lines changed

.github/workflows/checks.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
prettier:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
- run: npx prettier --check .

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"editor.tabSize": 2
3-
}
3+
}

CODE_OF_CONDUCT.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
88

99
Examples of behavior that contributes to creating a positive environment include:
1010

11-
* Using welcoming and inclusive language
12-
* Being respectful of differing viewpoints and experiences
13-
* Gracefully accepting constructive criticism
14-
* Focusing on what is best for the community
15-
* Showing empathy towards other community members
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
1616

1717
Examples of unacceptable behavior by participants include:
1818

19-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20-
* Trolling, insulting/derogatory comments, and personal or political attacks
21-
* Public or private harassment
22-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23-
* Other conduct which could reasonably be considered inappropriate in a professional setting
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
2424

2525
## Our Responsibilities
2626

codecov.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

demo/12.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const memfs = require('../lib');
22

3-
4-
memfs.fs.writeFileSync('/watson.json', JSON.stringify({
5-
"ocorrencia_id": 9001
6-
}));
7-
3+
memfs.fs.writeFileSync(
4+
'/watson.json',
5+
JSON.stringify({
6+
ocorrencia_id: 9001,
7+
}),
8+
);
89

910
console.log(memfs.fs.readFileSync('/watson.json', 'utf8'));

demo/JSON.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Volume} from '../src/volume';
1+
import { Volume } from '../src/volume';
22

3-
4-
const vol = Volume.fromJSON({
3+
const vol = Volume.fromJSON(
4+
{
55
'./src/index.js': `
66
import React from 'react';
77
import {render} from 'react-dom';
@@ -19,8 +19,9 @@ This is some super cool project.
1919
`,
2020

2121
'.node_modules/EMPTY': '',
22-
23-
}, '/app');
22+
},
23+
'/app',
24+
);
2425

2526
console.log(vol.toJSON());
2627
console.log(vol.readFileSync('/app/src/index.js', 'utf8'));

demo/createReadStream.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {vol} from '../src/index';
1+
import { vol } from '../src/index';
22

33
vol.writeFileSync('/readme', '# Hello World');
44
const rs = vol.createReadStream('/readme', 'utf8');
5-
rs.on('data', (data) => {
6-
console.log('data', data.toString());
5+
rs.on('data', data => {
6+
console.log('data', data.toString());
77
});

demo/createWriteStream.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {vol} from '../src/index';
2-
1+
import { vol } from '../src/index';
32

43
const ws = vol.createWriteStream('/readme', 'utf8');
54
ws.end('lol');
65
ws.on('finish', () => {
7-
console.log(vol.readFileSync('/readme').toString());
6+
console.log(vol.readFileSync('/readme').toString());
87
});

demo/localstorage.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import {createVolume} from '../src/volume-localstorage';
1+
import { createVolume } from '../src/volume-localstorage';
22

33
const obj = {};
44
const Volume = createVolume('default', obj);
55

6-
const vol = new Volume;
7-
vol.fromJSON({'/foo': 'bar', '/foo2': 'bar2'});
6+
const vol = new Volume();
7+
vol.fromJSON({ '/foo': 'bar', '/foo2': 'bar2' });
88
// vol.unlinkSync('/foo');
99

1010
console.log(obj);
1111
console.log(vol.toJSON());
12-
13-
14-

demo/mountSync.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import {Volume} from '../src/index';
1+
import { Volume } from '../src/index';
22

3-
4-
const vol = new Volume;
3+
const vol = new Volume();
54
vol.mountSync('/test', {
6-
'foo': 'bar',
5+
foo: 'bar',
76
});
87

9-
10-
console.log(vol.toJSON());
8+
console.log(vol.toJSON());

demo/permissions.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {Volume} from '../src/index';
1+
import { Volume } from '../src/index';
22

3-
4-
const vol = Volume.fromJSON({'/foo': 'bar'});
3+
const vol = Volume.fromJSON({ '/foo': 'bar' });
54

65
console.log(vol.readFileSync('/foo', 'utf8'));
76

demo/readFileSync.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {fs} from '../src/index';
2-
1+
import { fs } from '../src/index';
32

43
fs.writeFileSync('/test.txt', 'hello...');
54
console.log(fs.readFileSync('/test.txt', 'utf8'));

demo/relative-path.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {Volume} from '../src/volume';
1+
import { Volume } from '../src/volume';
22

3-
4-
const vol = Volume.fromJSON({'./README': 'Hello'});
3+
const vol = Volume.fromJSON({ './README': 'Hello' });
54

65
console.log(vol.toJSON());
76
console.log(vol.readdirSync('/home'));

demo/rename.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Volume} from "../src/volume";
1+
import { Volume } from '../src/volume';
22

3-
const vol = Volume.fromJSON({'/foo/foo': 'bar'});
3+
const vol = Volume.fromJSON({ '/foo/foo': 'bar' });
44
vol.renameSync('/foo/foo', '/foo/foo2');
55
console.log(vol.toJSON());

demo/symlink.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import {vol} from '../src';
1+
import { vol } from '../src';
22

3-
vol.fromJSON({'/a1/a2/a3/a4/a5/hello.txt': 'world!'});
3+
vol.fromJSON({ '/a1/a2/a3/a4/a5/hello.txt': 'world!' });
44
console.log(vol.readFileSync('/a1/a2/a3/a4/a5/hello.txt', 'utf8'));
55

6-
76
vol.symlinkSync('/a1/a2/a3/a4/a5/hello.txt', '/link');
87
console.log(vol.readFileSync('/link', 'utf8'));
98

10-
119
vol.symlinkSync('/a1', '/b1');
1210
console.log(vol.readFileSync('/b1/a2/a3/a4/a5/hello.txt', 'utf8'));
1311

14-
1512
vol.symlinkSync('/a1/a2', '/b2');
1613
console.log(vol.readFileSync('/b2/a3/a4/a5/hello.txt', 'utf8'));
1714

18-
1915
vol.symlinkSync('/b2', '/c2');
2016
console.log(vol.readFileSync('/c2/a3/a4/a5/hello.txt', 'utf8'));
2117

22-
2318
vol.mkdirpSync('/d1/d2');
2419
vol.symlinkSync('/c2', '/d1/d2/to-c2');
2520
console.log(vol.readFileSync('/d1/d2/to-c2/a3/a4/a5/hello.txt', 'utf8'));

demo/toJSON.ts

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
import {Volume} from '../src/index';
2-
1+
import { Volume } from '../src/index';
32

43
const vol = Volume.fromJSON({
5-
'/foo': 'bar',
6-
'/dir1/file.js': '// comment...',
7-
'/dir2/index.js': 'process',
8-
'/dir2/main.js': 'console.log(123)',
4+
'/foo': 'bar',
5+
'/dir1/file.js': '// comment...',
6+
'/dir2/index.js': 'process',
7+
'/dir2/main.js': 'console.log(123)',
98
});
109
console.log(vol.toJSON());
1110

12-
1311
console.log(vol.toJSON('/dir2'));
1412

15-
1613
console.log(vol.toJSON('/dir1'));
1714

18-
1915
console.log(vol.toJSON(['/dir2', '/dir1']));
2016

21-
2217
console.log(vol.toJSON('/'));
2318

24-
25-
let a = {a: 1};
19+
let a = { a: 1 };
2620
console.log(vol.toJSON('/dir1', a));
2721

28-
29-
30-
console.log(vol.toJSON('/dir2', {}, true));
22+
console.log(vol.toJSON('/dir2', {}, true));

demo/watch.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3-
import {Volume} from '../src/volume';
4-
3+
import { Volume } from '../src/volume';
54

65
// const filename = path.join(__dirname, '../test/mock/text.txt');
76
// fs.watch(filename, (event, filename) => {
87
// console.log(event, filename);
98
// });
109

11-
const vol = Volume.fromJSON({'/hello.txt': 'World'});
10+
const vol = Volume.fromJSON({ '/hello.txt': 'World' });
1211
vol.watch('/hello.txt', {}, (event, filename) => {
13-
console.log(event, filename);
14-
console.log(vol.readFileSync('/hello.txt', 'utf8'));
12+
console.log(event, filename);
13+
console.log(vol.readFileSync('/hello.txt', 'utf8'));
1514
});
1615

1716
vol.appendFileSync('/hello.txt', '!');
1817

1918
setTimeout(() => {
20-
vol.appendFileSync('/hello.txt', ' OK?');
19+
vol.appendFileSync('/hello.txt', ' OK?');
2120
}, 1000);
22-

demo/write.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import {fs} from '../src/index';
2-
1+
import { fs } from '../src/index';
32

43
const fd = fs.openSync('/test.txt', 'w');
54
const data = '123';
65
fs.write(fd, Buffer.from(data), (err, bytes, buf) => {
7-
// console.log(err, bytes, buf);
8-
fs.closeSync(fd);
6+
// console.log(err, bytes, buf);
7+
fs.closeSync(fd);
98
});
10-

0 commit comments

Comments
 (0)