Skip to content

Commit 2885224

Browse files
committed
Apply the updated Prettier styling (#467)
1 parent 8f9aa45 commit 2885224

26 files changed

+1529
-1417
lines changed

.eslintrc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
module.exports = {
44
env: {
55
node: true,
6-
es6: true
6+
es6: true,
77
},
88

99
extends: ["prettier"],
1010

1111
parserOptions: {
12-
ecmaVersion: 9
12+
ecmaVersion: 9,
1313
},
1414

1515
globals: {
1616
fetch: false,
17-
WebAssembly: false
17+
WebAssembly: false,
1818
},
1919

2020
rules: {
@@ -142,9 +142,9 @@ module.exports = {
142142
ArrayExpression: true,
143143
AssignmentExpression: true,
144144
ObjectExpression: true,
145-
VariableDeclarator: true
146-
}
147-
}
145+
VariableDeclarator: true,
146+
},
147+
},
148148
],
149149

150150
// No reassigning native JS objects
@@ -215,8 +215,8 @@ module.exports = {
215215
"error",
216216
{
217217
args: "none",
218-
vars: "local"
219-
}
218+
vars: "local",
219+
},
220220
],
221221

222222
// No using variables before defined
@@ -256,6 +256,6 @@ module.exports = {
256256
// Only check typeof against valid results
257257
"valid-typeof": "error",
258258

259-
"max-len": ["error", { code: 120, ignoreUrls: true }]
260-
}
259+
"max-len": ["error", { code: 120, ignoreUrls: true }],
260+
},
261261
};

.github/workflows/cargo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
name: WASM tests
99

1010
defaults:
11-
run:
12-
working-directory: ./wasm-mappings
11+
run:
12+
working-directory: ./wasm-mappings
1313

1414
jobs:
1515
build_and_test:

.waiting.html

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<title>Code coverage report for All files</title>
5-
<style>
6-
body {
7-
font-family: Helvetica Neue, Helvetica, Arial;
8-
font-size: 20px;
9-
color:#333;
10-
margin: 50px;
11-
}
12-
code {
13-
color: green;
14-
}
15-
</style>
16-
</head>
17-
<body>
18-
<div>This page will refresh with a coverage report, as long as you have
19-
executed <code>npm run dev</code>. Please be patient.</div>
20-
</body>
21-
</html>
3+
<head>
4+
<title>Code coverage report for All files</title>
5+
<style>
6+
body {
7+
font-family: Helvetica Neue, Helvetica, Arial;
8+
font-size: 20px;
9+
color: #333;
10+
margin: 50px;
11+
}
12+
code {
13+
color: green;
14+
}
15+
</style>
16+
</head>
17+
<body>
18+
<div>
19+
This page will refresh with a coverage report, as long as you have
20+
executed <code>npm run dev</code>. Please be patient.
21+
</div>
22+
</body>
23+
</html>

README.md

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ This is a library to generate and consume the source map format
1616
```html
1717
<script src="https://unpkg.com/[email protected]/dist/source-map.js"></script>
1818
<script>
19-
sourceMap.SourceMapConsumer.initialize({
20-
"lib/mappings.wasm": "https://unpkg.com/[email protected]/lib/mappings.wasm"
21-
});
19+
sourceMap.SourceMapConsumer.initialize({
20+
"lib/mappings.wasm": "https://unpkg.com/[email protected]/lib/mappings.wasm",
21+
});
2222
</script>
2323
```
24+
2425
---
2526

2627
<!-- `npm run toc` to regenerate the Table of Contents -->
@@ -81,7 +82,8 @@ const rawSourceMap = {
8182
names: ["bar", "baz", "n"],
8283
sources: ["one.js", "two.js"],
8384
sourceRoot: "http://example.com/www/js/",
84-
mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
85+
mappings:
86+
"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA",
8587
};
8688

8789
const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => {
@@ -92,7 +94,7 @@ const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => {
9294
console.log(
9395
consumer.originalPositionFor({
9496
line: 2,
95-
column: 28
97+
column: 28,
9698
})
9799
);
98100
// { source: 'http://example.com/www/js/two.js',
@@ -104,12 +106,12 @@ const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => {
104106
consumer.generatedPositionFor({
105107
source: "http://example.com/www/js/two.js",
106108
line: 2,
107-
column: 10
109+
column: 10,
108110
})
109111
);
110112
// { line: 2, column: 28 }
111113

112-
consumer.eachMapping(function(m) {
114+
consumer.eachMapping(function (m) {
113115
// ...
114116
});
115117

@@ -128,13 +130,19 @@ In depth guide:
128130
function compile(ast) {
129131
switch (ast.type) {
130132
case "BinaryExpression":
131-
return new SourceNode(ast.location.line, ast.location.column, ast.location.source, [
132-
compile(ast.left),
133-
" + ",
134-
compile(ast.right)
135-
]);
133+
return new SourceNode(
134+
ast.location.line,
135+
ast.location.column,
136+
ast.location.source,
137+
[compile(ast.left), " + ", compile(ast.right)]
138+
);
136139
case "Literal":
137-
return new SourceNode(ast.location.line, ast.location.column, ast.location.source, String(ast.value));
140+
return new SourceNode(
141+
ast.location.line,
142+
ast.location.column,
143+
ast.location.source,
144+
String(ast.value)
145+
);
138146
// ...
139147
default:
140148
throw new Error("Bad AST");
@@ -144,7 +152,7 @@ function compile(ast) {
144152
var ast = parse("40 + 2", "add.js");
145153
console.log(
146154
compile(ast).toStringWithSourceMap({
147-
file: "add.js"
155+
file: "add.js",
148156
})
149157
);
150158
// { code: '40 + 2',
@@ -155,20 +163,20 @@ console.log(
155163

156164
```js
157165
var map = new SourceMapGenerator({
158-
file: "source-mapped.js"
166+
file: "source-mapped.js",
159167
});
160168

161169
map.addMapping({
162170
generated: {
163171
line: 10,
164-
column: 35
172+
column: 35,
165173
},
166174
source: "foo.js",
167175
original: {
168176
line: 33,
169-
column: 2
177+
column: 2,
170178
},
171-
name: "christopher"
179+
name: "christopher",
172180
});
173181

174182
console.log(map.toString());
@@ -209,7 +217,7 @@ The options object has the following properties:
209217

210218
```js
211219
sourceMap.SourceMapConsumer.initialize({
212-
"lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm"
220+
"lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm",
213221
});
214222
```
215223

@@ -261,13 +269,17 @@ By using `with`, you do not have to remember to manually call `destroy` on
261269
the consumer, since it will be called automatically once `f` completes.
262270

263271
```js
264-
const xSquared = await SourceMapConsumer.with(myRawSourceMap, null, async function(consumer) {
265-
// Use `consumer` inside here and don't worry about remembering
266-
// to call `destroy`.
267-
268-
const x = await whatever(consumer);
269-
return x * x;
270-
});
272+
const xSquared = await SourceMapConsumer.with(
273+
myRawSourceMap,
274+
null,
275+
async function (consumer) {
276+
// Use `consumer` inside here and don't worry about remembering
277+
// to call `destroy`.
278+
279+
const x = await whatever(consumer);
280+
return x * x;
281+
}
282+
);
271283

272284
// You may not use that `consumer` anymore out here; it has
273285
// been destroyed. But you can use `xSquared`.
@@ -357,7 +369,7 @@ consumer.originalPositionFor({ line: 2, column: 10 });
357369

358370
consumer.originalPositionFor({
359371
line: 99999999999999999,
360-
column: 999999999999999
372+
column: 999999999999999,
361373
});
362374
// { source: null,
363375
// line: null,
@@ -490,7 +502,7 @@ generated line/column in this source map.
490502
`SourceMapConsumer.GENERATED_ORDER`.
491503

492504
```js
493-
consumer.eachMapping(function(m) {
505+
consumer.eachMapping(function (m) {
494506
console.log(m);
495507
});
496508
// ...
@@ -531,7 +543,7 @@ You may pass an object with the following properties:
531543
```js
532544
var generator = new sourceMap.SourceMapGenerator({
533545
file: "my-generated-javascript-file.js",
534-
sourceRoot: "http://example.com/app/js/"
546+
sourceRoot: "http://example.com/app/js/",
535547
});
536548
```
537549

@@ -563,7 +575,7 @@ should have the following properties:
563575
generator.addMapping({
564576
source: "module-one.scm",
565577
original: { line: 128, column: 0 },
566-
generated: { line: 3, column: 456 }
578+
generated: { line: 3, column: 456 },
567579
});
568580
```
569581

@@ -576,7 +588,10 @@ Set the source content for an original source file.
576588
- `sourceContent` the content of the source file.
577589

578590
```js
579-
generator.setSourceContent("module-one.scm", fs.readFileSync("path/to/module-one.scm"));
591+
generator.setSourceContent(
592+
"module-one.scm",
593+
fs.readFileSync("path/to/module-one.scm")
594+
);
580595
```
581596

582597
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])
@@ -640,7 +655,7 @@ use before outputting the generated JS and source map.
640655
var node = new SourceNode(1, 2, "a.cpp", [
641656
new SourceNode(3, 4, "b.cpp", "extern int status;\n"),
642657
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"),
643-
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n")
658+
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"),
644659
]);
645660
```
646661

@@ -656,8 +671,13 @@ Creates a SourceNode from generated code and a SourceMapConsumer.
656671
should be relative to.
657672

658673
```js
659-
const consumer = await new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
660-
const node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), consumer);
674+
const consumer = await new SourceMapConsumer(
675+
fs.readFileSync("path/to/my-file.js.map", "utf8")
676+
);
677+
const node = SourceNode.fromStringWithSourceMap(
678+
fs.readFileSync("path/to/my-file.js"),
679+
consumer
680+
);
661681
```
662682

663683
#### SourceNode.prototype.add(chunk)
@@ -694,7 +714,10 @@ Set the source content for a source file. This will be added to the
694714
- `sourceContent`: The content of the source file
695715

696716
```js
697-
node.setSourceContent("module-one.scm", fs.readFileSync("path/to/module-one.scm"));
717+
node.setSourceContent(
718+
"module-one.scm",
719+
fs.readFileSync("path/to/module-one.scm")
720+
);
698721
```
699722

700723
#### SourceNode.prototype.walk(fn)
@@ -709,10 +732,10 @@ the its original associated source's line/column location.
709732
var node = new SourceNode(1, 2, "a.js", [
710733
new SourceNode(3, 4, "b.js", "uno"),
711734
"dos",
712-
["tres", new SourceNode(5, 6, "c.js", "quatro")]
735+
["tres", new SourceNode(5, 6, "c.js", "quatro")],
713736
]);
714737

715-
node.walk(function(code, loc) {
738+
node.walk(function (code, loc) {
716739
console.log("WALK:", code, loc);
717740
});
718741
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }
@@ -737,7 +760,7 @@ var c = new SourceNode(1, 2, "c.js", "generated from c");
737760
c.setSourceContent("c.js", "original c");
738761

739762
var node = new SourceNode(null, null, null, [a, b, c]);
740-
node.walkSourceContents(function(source, contents) {
763+
node.walkSourceContents(function (source, contents) {
741764
console.log("WALK:", source, ":", contents);
742765
});
743766
// WALK: a.js : original a
@@ -784,7 +807,7 @@ concatenates all the various snippets together to one string.
784807
var node = new SourceNode(1, 2, "a.js", [
785808
new SourceNode(3, 4, "b.js", "uno"),
786809
"dos",
787-
["tres", new SourceNode(5, 6, "c.js", "quatro")]
810+
["tres", new SourceNode(5, 6, "c.js", "quatro")],
788811
]);
789812

790813
node.toString();
@@ -803,11 +826,10 @@ The arguments are the same as those to `new SourceMapGenerator`.
803826
var node = new SourceNode(1, 2, "a.js", [
804827
new SourceNode(3, 4, "b.js", "uno"),
805828
"dos",
806-
["tres", new SourceNode(5, 6, "c.js", "quatro")]
829+
["tres", new SourceNode(5, 6, "c.js", "quatro")],
807830
]);
808831

809832
node.toStringWithSourceMap({ file: "my-output-file.js" });
810833
// { code: 'unodostresquatro',
811834
// map: [object SourceMapGenerator] }
812835
```
813-

0 commit comments

Comments
 (0)