Skip to content

Commit e8d9efc

Browse files
committed
(chore) lint tools
1 parent 77bd822 commit e8d9efc

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

tools/lib/external_language.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const fs = require("fs")
2-
const fsProm = require("fs").promises
3-
const glob = require("glob-promise")
4-
const path = require("path")
1+
const fs = require("fs");
2+
const fsProm = require("fs").promises;
3+
const glob = require("glob-promise");
4+
const path = require("path");
55

66
const MODULE_DEFINER = /module\.exports\.definer\s*=/;
77

@@ -12,11 +12,11 @@ class LanguagePackage {
1212

1313
// check for language modules in /src/languages
1414
async trySrcLanguages() {
15-
let dir = path.join(this.dir,"src/languages/*");
16-
let languages = await glob(dir);
15+
const dir = path.join(this.dir, "src/languages/*");
16+
const languages = await glob(dir);
1717
if (languages.length > 0) {
1818
this.files = languages.map(fn => `./${fn}`);
19-
this.names = this.files.map(fn => path.basename(fn,".js"));
19+
this.names = this.files.map(fn => path.basename(fn, ".js"));
2020
this._bundle = true;
2121
this._valid = true;
2222
return true;
@@ -41,14 +41,14 @@ class LanguagePackage {
4141

4242
// try to find a language module by probing package.json
4343
async tryPackageJSON() {
44-
let pack = path.join(this.dir,"package.json");
44+
const pack = path.join(this.dir, "package.json");
4545
if (fs.existsSync(pack)) {
46-
let data = await fsProm.readFile(pack);
47-
let json = JSON.parse(data);
46+
const data = await fsProm.readFile(pack);
47+
const json = JSON.parse(data);
4848
if (json.main) {
4949
this.type = "npm";
50-
let file = path.join(process.cwd(),this.dir, json.main);
51-
let content = await fsProm.readFile(file, { encoding: "utf8" });
50+
const file = path.join(process.cwd(), this.dir, json.main);
51+
const content = await fsProm.readFile(file, { encoding: "utf8" });
5252
// many existing languages seem to export a `definer` function rather than
5353
// simply export the language module directly. This checks for that and if
5454
// so allows those existing modules to work "as is" by allowing the build
@@ -58,7 +58,7 @@ class LanguagePackage {
5858
this.loader = "definer";
5959
}
6060
this.files = [file];
61-
this.names = [path.basename(file,".js")];
61+
this.names = [path.basename(file, ".js")];
6262
this._valid = true;
6363
return true;
6464
}
@@ -71,17 +71,17 @@ class LanguagePackage {
7171
// any bundle with files in ROOT/src/languages/ will be considered a potential
7272
// multi language bundle and any files in that directy will be considered to be
7373
// language modules
74-
await this.trySrcLanguages() ||
74+
await this.trySrcLanguages()
7575
// otherwise we fall back to looking for a package.json and whatever it's
7676
// `main` entry point is that is the file we assume the language module is
7777
// defined in
78-
await this.tryPackageJSON();
78+
|| await this.tryPackageJSON();
7979
this._detected = true;
8080
}
8181

8282
async valid() {
8383
if (!this._detected) {
84-
await this.detect()
84+
await this.detect();
8585
}
8686
return this._valid;
8787
}
@@ -90,16 +90,16 @@ class LanguagePackage {
9090
// third party language modules are dropped into the `highlight-js/extra`
9191
// folder and will be auto-detected by the build system
9292
async function getThirdPartyPackages() {
93-
let packages = [];
94-
let otherPackages = await glob("./extra/*");
95-
for (let packageDir of otherPackages) {
96-
let thirdPartyPackage = new LanguagePackage(packageDir)
97-
let valid = await thirdPartyPackage.valid();
93+
const packages = [];
94+
const otherPackages = await glob("./extra/*");
95+
for (const packageDir of otherPackages) {
96+
const thirdPartyPackage = new LanguagePackage(packageDir);
97+
const valid = await thirdPartyPackage.valid();
9898
if (valid) {
99-
packages.push(thirdPartyPackage)
99+
packages.push(thirdPartyPackage);
100100
}
101101
}
102102
return packages;
103103
}
104104

105-
module.exports = { LanguagePackage, getThirdPartyPackages}
105+
module.exports = { LanguagePackage, getThirdPartyPackages };

tools/lib/language.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Language {
7373
return new Language(
7474
path.basename(filename).replace(".js",""),
7575
filename
76-
)
76+
);
7777
}
7878
}
7979

0 commit comments

Comments
 (0)