Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ersachin3112 committed Feb 28, 2024
1 parent fbec618 commit 5e62be7
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

# - name: Security audit
# run: npm run security

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ type sources =
tag: string,
attribute: string,
attributes: string,
resourcePath: string,
resourcePath: string
) => boolean;
}>;
urlFilter?: (
attribute: string,
value: string,
resourcePath: string,
resourcePath: string
) => boolean;
scriptingEnabled?: boolean;
};
Expand Down Expand Up @@ -210,7 +210,7 @@ type list = Array<{
tag: string,
attribute: string,
attributes: string,
resourcePath: string,
resourcePath: string
) => boolean;
}>;
```
Expand Down Expand Up @@ -411,7 +411,7 @@ Type:
type urlFilter = (
attribute: string,
value: string,
resourcePath: string,
resourcePath: string
) => boolean;
```

Expand Down Expand Up @@ -492,7 +492,7 @@ Type:
```ts
type preprocessor = (
content: string | Buffer,
loaderContext: LoaderContext,
loaderContext: LoaderContext
) => HTMLElement;
```

Expand Down Expand Up @@ -876,7 +876,7 @@ a {
**file.html**

```html
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function loader(content) {
imports,
errors,
replacements,
}),
})
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/sources-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default (options) =>

const attributeAndValue = html.slice(
sourceCodeLocation.attrs[name].startOffset,
sourceCodeLocation.attrs[name].endOffset,
sourceCodeLocation.attrs[name].endOffset
);
const isValueQuoted =
attributeAndValue[attributeAndValue.length - 1] === '"' ||
Expand Down
24 changes: 12 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export function parseSrcset(input) {
candidates.push(candidate);
} else {
throw new Error(
`Invalid srcset descriptor found in '${input}' at '${desc}'`,
`Invalid srcset descriptor found in '${input}' at '${desc}'`
);
}
}
Expand Down Expand Up @@ -695,7 +695,7 @@ export function srcType(options) {
`Bad value for attribute "${options.attribute}" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand All @@ -706,7 +706,7 @@ export function srcType(options) {
`Bad value for attribute "${options.attribute}" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand All @@ -730,7 +730,7 @@ export function srcsetType(options) {
`Bad value for attribute "${options.attribute}" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand All @@ -746,7 +746,7 @@ export function srcsetType(options) {
`Bad value for attribute "${options.attribute}" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand All @@ -769,7 +769,7 @@ function metaContentType(options) {
const isMsapplicationTask = options.attributes.find(
(i) =>
i.name.toLowerCase() === "name" &&
i.value.toLowerCase() === "msapplication-task",
i.value.toLowerCase() === "msapplication-task"
);

if (isMsapplicationTask) {
Expand All @@ -796,7 +796,7 @@ function metaContentType(options) {
`Bad value for attribute "icon-uri" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand All @@ -807,7 +807,7 @@ function metaContentType(options) {
`Bad value for attribute "icon-uri" on element "${options.tag}": ${error.message}`,
options.attributeStartOffset,
options.attributeEndOffset,
options.html,
options.html
);
}

Expand Down Expand Up @@ -1241,7 +1241,7 @@ export function getImportCode(html, loaderContext, imports, options) {
default:
code += options.esModule
? `var ${importName} = new URL(${JSON.stringify(
request,
request
)}, import.meta.url);\n`
: `var ${importName} = require(${JSON.stringify(request)});\n`;
}
Expand All @@ -1254,7 +1254,7 @@ export function getModuleCode(html, replacements) {
let code = JSON.stringify(html)
// Invalid in JavaScript but valid HTML
.replace(/[\u2028\u2029]/g, (str) =>
str === "\u2029" ? "\\u2029" : "\\u2028",
str === "\u2029" ? "\\u2029" : "\\u2028"
);

let replacersCode = "";
Expand All @@ -1273,12 +1273,12 @@ export function getModuleCode(html, replacements) {

code = code.replace(
new RegExp(replacementName, "g"),
() => `" + ${replacementName} + "`,
() => `" + ${replacementName} + "`
);
} else {
code = code.replace(
new RegExp(replacementName, "g"),
() => `" + ${importName} + "`,
() => `" + ${importName} + "`

Check warning on line 1281 in src/utils.js

View check run for this annotation

Codecov / codecov/patch

src/utils.js#L1281

Added line #L1281 was not covered by tests
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/esModule-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("'esModule' option", () => {

expect(getModuleSource("./simple.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -27,7 +27,7 @@ describe("'esModule' option", () => {

expect(getModuleSource("./simple.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -39,7 +39,7 @@ describe("'esModule' option", () => {

expect(getModuleSource("./simple.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export default (code) => {
const module = new Module(resource, parentModule);
// eslint-disable-next-line no-underscore-dangle
module.paths = Module._nodeModulePaths(
path.resolve(__dirname, "../fixtures"),
path.resolve(__dirname, "../fixtures")
);
module.filename = resource;

// eslint-disable-next-line no-underscore-dangle
module._compile(
`${code};module.exports = ___TEST___.default ?___TEST___.default : ___TEST___;`,
resource,
resource
);

return replaceAbsolutePath(module.exports);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/getCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default (fixture, loaderOptions = {}, config = {}) => {
aliasImg: path.resolve(__dirname, "../fixtures/image.png"),
aliasImageWithSpace: path.resolve(
__dirname,
"../fixtures/image image.png",
"../fixtures/image image.png"
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/normalizeErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ function removeCWD(str) {

export default (errors) =>
errors.map((error) =>
removeCWD(error.toString().split("\n").slice(0, 2).join("\n")),
removeCWD(error.toString().split("\n").slice(0, 2).join("\n"))
);
36 changes: 18 additions & 18 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("loader", () => {

expect(getModuleSource("./simple.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -32,7 +32,7 @@ describe("loader", () => {

expect(getModuleSource("./empty.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -44,15 +44,15 @@ describe("loader", () => {

expect(getModuleSource("./template.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it("should not failed contain invisible spaces", async () => {
const source = fs.readFileSync(
path.resolve(__dirname, "./fixtures/invisible-space.html"),
path.resolve(__dirname, "./fixtures/invisible-space.html")
);

expect(/[\u2028\u2029]/.test(source)).toBe(true);
Expand All @@ -65,7 +65,7 @@ describe("loader", () => {
expect(moduleSource).toMatchSnapshot("module");
expect(/[\u2028\u2029]/.test(moduleSource)).toBe(false);
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -76,10 +76,10 @@ describe("loader", () => {
const stats = await compile(compiler);

expect(getModuleSource("./broken-html-syntax.html", stats)).toMatchSnapshot(
"module",
"module"
);
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -91,7 +91,7 @@ describe("loader", () => {

expect(getModuleSource("./nested.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -105,13 +105,13 @@ describe("loader", () => {
resolve: {
roots: [path.resolve(__dirname, "fixtures/roots")],
},
},
}
);
const stats = await compile(compiler);

expect(getModuleSource("./roots.html", stats)).toMatchSnapshot("module");
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -130,7 +130,7 @@ describe("loader", () => {
// 'module'
// );
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -150,7 +150,7 @@ describe("loader", () => {
use: {
loader: path.resolve(
__dirname,
"./helpers/svg-color-loader.js",
"./helpers/svg-color-loader.js"
),
},
},
Expand All @@ -160,15 +160,15 @@ describe("loader", () => {
},
],
},
},
}
);
const stats = await compile(compiler);

expect(getModuleSource("./other-loader-query.html", stats)).toMatchSnapshot(
"module",
"module"
);
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand All @@ -179,10 +179,10 @@ describe("loader", () => {
const stats = await compile(compiler);

expect(getModuleSource("./webpackIgnore.html", stats)).toMatchSnapshot(
"module",
"module"
);
expect(
execute(readAsset("main.bundle.js", compiler, stats)),
execute(readAsset("main.bundle.js", compiler, stats))
).toMatchSnapshot("result");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
Expand Down Expand Up @@ -210,7 +210,7 @@ describe("loader", () => {
template: path.resolve(__dirname, "fixtures/template-html.html"),
}),
],
},
}
);
const stats = await compile(compiler);

Expand Down
Loading

0 comments on commit 5e62be7

Please sign in to comment.