Skip to content

Commit 400dd2e

Browse files
committed
test: eslint in loaders
1 parent beb4571 commit 400dd2e

File tree

32 files changed

+208
-224
lines changed

32 files changed

+208
-224
lines changed

demo/esm/test/loaders/all.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
2-
import * as coffee from './coffee.js'
3-
import * as ts from 'ts-node/esm'
1+
import * as coffee from "./coffee.js";
2+
import * as ts from "ts-node/esm";
43

54
const coffeeRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
65
const tsRegex = /\.ts$/;
76

87
export function load(url, context, next) {
98
if (coffeeRegex.test(url)) {
10-
return coffee.load.apply(this, arguments)
9+
return coffee.load.apply(this, arguments);
1110
}
1211
if (tsRegex.test(url)) {
13-
return ts.load.apply(this, arguments)
12+
return ts.load.apply(this, arguments);
1413
}
1514
return next(url, context, next);
1615
}

demo/esm/test/loaders/coffee.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import CoffeeScript from 'coffeescript';
1+
import CoffeeScript from "coffeescript";
22

33
// See https://github.com/nodejs/node/issues/36396
44
const extensionsRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
55

66
export async function load(url, context, next) {
77
if (extensionsRegex.test(url)) {
8-
const format = 'module';
8+
const format = "module";
99
const { source: rawSource } = await next(url, { format });
1010
const source = CoffeeScript.compile(rawSource.toString(), {
1111
bare: true,
@@ -14,7 +14,7 @@ export async function load(url, context, next) {
1414
header: false,
1515
sourceMap: false,
1616
});
17-
return {format, source};
17+
return { format, source };
1818
}
1919
return next(url, context);
2020
}

demo/esm/test/loaders/legacy/all.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
2-
import * as coffee from './coffee.js'
3-
import * as ts from 'ts-node/esm'
1+
import * as coffee from "./coffee.js";
2+
import * as ts from "ts-node/esm";
43

54
const coffeeRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
65
const tsRegex = /\.ts$/;
76

8-
export function resolve(specifier, context, defaultResolve) {
7+
export function resolve(specifier) {
98
if (coffeeRegex.test(specifier)) {
10-
return coffee.resolve.apply(this, arguments)
9+
return coffee.resolve.apply(this, arguments);
1110
}
1211
if (tsRegex.test(specifier)) {
13-
return ts.resolve.apply(this, arguments)
12+
return ts.resolve.apply(this, arguments);
1413
}
1514
return ts.resolve.apply(this, arguments);
1615
}
1716

18-
export function getFormat(url, context, defaultGetFormat) {
17+
export function getFormat(url) {
1918
if (coffeeRegex.test(url)) {
20-
return coffee.getFormat.apply(this, arguments)
19+
return coffee.getFormat.apply(this, arguments);
2120
}
2221
if (tsRegex.test(url)) {
23-
return ts.getFormat.apply(this, arguments)
22+
return ts.getFormat.apply(this, arguments);
2423
}
2524
return ts.getFormat.apply(this, arguments);
2625
}
2726

28-
export function transformSource(source, context, defaultTransformSource) {
27+
export function transformSource(source, context) {
2928
const { url } = context;
3029
if (coffeeRegex.test(url)) {
31-
return coffee.transformSource.apply(this, arguments)
30+
return coffee.transformSource.apply(this, arguments);
3231
}
3332
if (tsRegex.test(url)) {
34-
return ts.transformSource.apply(this, arguments)
33+
return ts.transformSource.apply(this, arguments);
3534
}
3635
return ts.transformSource.apply(this, arguments);
3736
}

demo/esm/test/loaders/legacy/coffee.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// coffeescript-loader.mjs
2-
import { URL, pathToFileURL } from 'url';
3-
import CoffeeScript from 'coffeescript';
4-
import { cwd } from 'process';
2+
import { URL, pathToFileURL } from "url";
3+
import CoffeeScript from "coffeescript";
4+
import { cwd } from "process";
55

66
const baseURL = pathToFileURL(`${cwd()}/`).href;
77

@@ -15,7 +15,7 @@ export function resolve(specifier, context, defaultResolve) {
1515
if (extensionsRegex.test(specifier)) {
1616
return {
1717
url: new URL(specifier, parentURL).href,
18-
stop: true
18+
stop: true,
1919
};
2020
}
2121
// Let Node.js handle all other specifiers.
@@ -28,20 +28,20 @@ export function getFormat(url, context, defaultGetFormat) {
2828
// purposes of this loader, all CoffeeScript URLs are ES modules.
2929
if (extensionsRegex.test(url)) {
3030
return {
31-
format: 'module',
32-
stop: true
31+
format: "module",
32+
stop: true,
3333
};
3434
}
3535
// Let Node.js handle all other URLs.
3636
return defaultGetFormat(url, context, defaultGetFormat);
3737
}
3838

3939
export function transformSource(source, context, defaultTransformSource) {
40-
const { url, format } = context;
40+
const { url } = context;
4141

4242
if (extensionsRegex.test(url)) {
4343
return {
44-
source: CoffeeScript.compile(String(source), { bare: true })
44+
source: CoffeeScript.compile(String(source), { bare: true }),
4545
};
4646
}
4747

demo/issues-esm/test/loaders/all.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
2-
import * as coffee from './coffee.js'
3-
import * as ts from 'ts-node/esm'
1+
import * as coffee from "./coffee.js";
2+
import * as ts from "ts-node/esm";
43

54
const coffeeRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
65
const tsRegex = /\.ts$/;
76

87
export function load(url, context, next) {
98
if (coffeeRegex.test(url)) {
10-
return coffee.load.apply(this, arguments)
9+
return coffee.load.apply(this, arguments);
1110
}
1211
if (tsRegex.test(url)) {
13-
return ts.load.apply(this, arguments)
12+
return ts.load.apply(this, arguments);
1413
}
1514
return next(url, context, next);
1615
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import CoffeeScript from 'coffeescript';
1+
import CoffeeScript from "coffeescript";
22

33
// See https://github.com/nodejs/node/issues/36396
44
const extensionsRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
55

66
export async function load(url, context, next) {
77
if (extensionsRegex.test(url)) {
8-
const format = 'module';
8+
const format = "module";
99
const { source: rawSource } = await next(url, { format });
1010
const source = CoffeeScript.compile(rawSource.toString(), {
1111
bare: true,
@@ -14,7 +14,7 @@ export async function load(url, context, next) {
1414
header: false,
1515
sourceMap: false,
1616
});
17-
return {format, source};
17+
return { format, source };
1818
}
1919
return next(url, context);
2020
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
2-
import * as coffee from './coffee.js'
3-
import * as ts from 'ts-node/esm'
1+
import * as coffee from "./coffee.js";
2+
import * as ts from "ts-node/esm";
43

54
const coffeeRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
65
const tsRegex = /\.ts$/;
76

8-
export function resolve(specifier, context, defaultResolve) {
7+
export function resolve(specifier) {
98
if (coffeeRegex.test(specifier)) {
10-
return coffee.resolve.apply(this, arguments)
9+
return coffee.resolve.apply(this, arguments);
1110
}
1211
if (tsRegex.test(specifier)) {
13-
return ts.resolve.apply(this, arguments)
12+
return ts.resolve.apply(this, arguments);
1413
}
1514
return ts.resolve.apply(this, arguments);
1615
}
1716

18-
export function getFormat(url, context, defaultGetFormat) {
17+
export function getFormat(url) {
1918
if (coffeeRegex.test(url)) {
20-
return coffee.getFormat.apply(this, arguments)
19+
return coffee.getFormat.apply(this, arguments);
2120
}
2221
if (tsRegex.test(url)) {
23-
return ts.getFormat.apply(this, arguments)
22+
return ts.getFormat.apply(this, arguments);
2423
}
2524
return ts.getFormat.apply(this, arguments);
2625
}
2726

28-
export function transformSource(source, context, defaultTransformSource) {
27+
export function transformSource(source, context) {
2928
const { url } = context;
3029
if (coffeeRegex.test(url)) {
31-
return coffee.transformSource.apply(this, arguments)
30+
return coffee.transformSource.apply(this, arguments);
3231
}
3332
if (tsRegex.test(url)) {
34-
return ts.transformSource.apply(this, arguments)
33+
return ts.transformSource.apply(this, arguments);
3534
}
3635
return ts.transformSource.apply(this, arguments);
3736
}

demo/issues-esm/test/loaders/legacy/coffee.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// coffeescript-loader.mjs
2-
import { URL, pathToFileURL } from 'url';
3-
import CoffeeScript from 'coffeescript';
4-
import { cwd } from 'process';
2+
import { URL, pathToFileURL } from "url";
3+
import CoffeeScript from "coffeescript";
4+
import { cwd } from "process";
55

66
const baseURL = pathToFileURL(`${cwd()}/`).href;
77

@@ -15,7 +15,7 @@ export function resolve(specifier, context, defaultResolve) {
1515
if (extensionsRegex.test(specifier)) {
1616
return {
1717
url: new URL(specifier, parentURL).href,
18-
stop: true
18+
stop: true,
1919
};
2020
}
2121
// Let Node.js handle all other specifiers.
@@ -28,20 +28,20 @@ export function getFormat(url, context, defaultGetFormat) {
2828
// purposes of this loader, all CoffeeScript URLs are ES modules.
2929
if (extensionsRegex.test(url)) {
3030
return {
31-
format: 'module',
32-
stop: true
31+
format: "module",
32+
stop: true,
3333
};
3434
}
3535
// Let Node.js handle all other URLs.
3636
return defaultGetFormat(url, context, defaultGetFormat);
3737
}
3838

3939
export function transformSource(source, context, defaultTransformSource) {
40-
const { url, format } = context;
40+
const { url } = context;
4141

4242
if (extensionsRegex.test(url)) {
4343
return {
44-
source: CoffeeScript.compile(String(source), { bare: true })
44+
source: CoffeeScript.compile(String(source), { bare: true }),
4545
};
4646
}
4747

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
2-
import * as coffee from './coffee.js'
3-
import * as ts from 'ts-node/esm'
1+
import * as coffee from "./coffee.js";
2+
import * as ts from "ts-node/esm";
43

54
const coffeeRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
65
const tsRegex = /\.ts$/;
76

87
export function load(url, context, next) {
98
if (coffeeRegex.test(url)) {
10-
return coffee.load.apply(this, arguments)
9+
return coffee.load.apply(this, arguments);
1110
}
1211
if (tsRegex.test(url)) {
13-
return ts.load.apply(this, arguments)
12+
return ts.load.apply(this, arguments);
1413
}
1514
return next(url, context, next);
1615
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import CoffeeScript from 'coffeescript';
1+
import CoffeeScript from "coffeescript";
22

33
// See https://github.com/nodejs/node/issues/36396
44
const extensionsRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
55

66
export async function load(url, context, next) {
77
if (extensionsRegex.test(url)) {
8-
const format = 'module';
8+
const format = "module";
99
const { source: rawSource } = await next(url, { format });
1010
const source = CoffeeScript.compile(rawSource.toString(), {
1111
bare: true,
@@ -14,7 +14,7 @@ export async function load(url, context, next) {
1414
header: false,
1515
sourceMap: false,
1616
});
17-
return {format, source};
17+
return { format, source };
1818
}
1919
return next(url, context);
2020
}

0 commit comments

Comments
 (0)