Skip to content

Commit bd7a1a3

Browse files
committed
lint issues
1 parent 0406774 commit bd7a1a3

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

tools/highlight-files/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ ts_library(
88
srcs = glob(["**/*.ts"]),
99
tsconfig = ":tsconfig.json",
1010
deps = [
11-
"@npm//@types/node",
11+
"//tools/region-parser",
1212
"@npm//@types/fs-extra",
13-
"//tools/region-parser"
13+
"@npm//@types/node",
1414
],
1515
)
1616

tools/highlight-files/highlight-files.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ if (require.main === module) {
4343
const parsed = regionParser(readFileSync(execPath, 'utf8'), fileExtension);
4444
for (const [regionName, regionSnippet] of Object.entries(parsed.regions)) {
4545
// Create files for each found region
46-
if (!regionName) continue;
47-
const highlightedCodeSnippet = highlightCodeBlock(regionSnippet, fileExtension);
46+
if (!regionName) { continue; }
47+
const highlightedRegion = highlightCodeBlock(regionSnippet, fileExtension);
4848
// Convert "my-component-example.ts" into "my-component-example_region-ts.html"
49-
const basePathOutputPath = basePath.replace(`.${fileExtension}`,
49+
const regionBaseOutputPath = basePath.replace(`.${fileExtension}`,
5050
`_${regionName}-${fileExtension}.html`);
51-
const outputPath = join(outDir, basePathOutputPath);
52-
ensureDirSync(dirname(outputPath));
53-
writeFileSync(outputPath, highlightedCodeSnippet);
51+
const regionOutputPath = join(outDir, regionBaseOutputPath);
52+
ensureDirSync(dirname(regionOutputPath));
53+
writeFileSync(regionOutputPath, highlightedRegion);
5454
}
5555
// Convert "my-component-example.ts" into "my-component-example-ts.html"
5656
const baseOutputPath = basePath.replace(`.${fileExtension}`, `-${fileExtension}.html`);

tools/highlight-files/index.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def _highlight_files(ctx):
3030
# be processed by the highlight binary.
3131
args.add_all(input_files)
3232

33-
3433
# Run the highlight-files executable that highlights the specified source files.
3534
ctx.actions.run(
3635
inputs = input_files,

tools/package-docs-content/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ nodejs_binary(
77
name = "package-docs-content",
88
data = [
99
":sources",
10-
"@npm//fs-extra"
10+
"@npm//fs-extra",
1111
],
1212
entry_point = ":package-docs-content.ts",
1313
)
@@ -17,7 +17,7 @@ ts_library(
1717
srcs = glob(["**/*.ts"]),
1818
tsconfig = ":tsconfig.json",
1919
deps = [
20-
"@npm//@types/node",
2120
"@npm//@types/fs-extra",
21+
"@npm//@types/node",
2222
],
2323
)

tools/package-docs-content/index.bzl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ def _package_docs_content(ctx):
1313
# repeat `docs-content` is for
1414
output_dir = ctx.actions.declare_directory("%s/%s" % (ctx.attr.name, ctx.attr.name))
1515

16-
17-
1816
# Support passing arguments through a parameter file. This is necessary because on Windows
1917
# there is an argument limit and we need to handle a large amount of input files. Bazel
2018
# switches between parameter file and normal argument passing based on the operating system.
2119
# Read more here: https://docs.bazel.build/versions/master/skylark/lib/Args.html#use_param_file
2220
args.use_param_file(param_file_arg = "--param-file=%s", use_always = True)
2321

24-
2522
# Walk through each defined input target and the associated section and compute the
2623
# output file which will be added to the executable arguments.
2724
for input_target, section_name in ctx.attr.srcs.items():
@@ -44,8 +41,6 @@ def _package_docs_content(ctx):
4441
else:
4542
expected_out_path = "%s/%s" % (output_dir.path, section_relative_file_name)
4643

47-
48-
4944
# Pass the input file path and the output file path to the packager executable. We need
5045
# to do this for each file because we cannot determine the general path to the output
5146
# directory in a reliable way because Bazel targets cannot just "declare" a directory.

tools/region-parser/region-parser.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export function regionParser(contents: string, fileType: string) {
1414
* @param fileType string
1515
* @returns {contents: string, regions: {[regionName: string]: string}}
1616
*/
17-
function regionParserImpl(contents: string, fileType: string): {contents: string, regions: {[regionName: string]: string}} {
17+
function regionParserImpl(contents: string, fileType: string)
18+
: {contents: string, regions: {[regionName: string]: string}} {
1819
const regionMatchers: {[fileType: string]: {[region: string]: RegExp}} = {
1920
ts: inlineC,
2021
js: inlineC,
@@ -23,7 +24,7 @@ function regionParserImpl(contents: string, fileType: string): {contents: string
2324
css: blockC,
2425
json: inlineC,
2526
'json.annotated': inlineC
26-
}
27+
};
2728
const regionMatcher = regionMatchers[fileType];
2829
const openRegions: string[] = [];
2930
const regionMap: RegionMap = {};
@@ -46,7 +47,8 @@ function regionParserImpl(contents: string, fileType: string): {contents: string
4647
if (region) {
4748
if (region.open) {
4849
throw new Error(
49-
`Tried to open a region, named "${regionName}", that is already open`);
50+
`Tried to open a region, named "${regionName}", that is already open`
51+
);
5052
}
5153
region.open = true;
5254
} else {
@@ -90,15 +92,16 @@ function regionParserImpl(contents: string, fileType: string): {contents: string
9092
}
9193
return {
9294
contents: lines.join('\n'),
93-
regions: mapObject(regionMap, (regionName: string, region: Region) => leftAlign(region.lines).join('\n'))
95+
regions: mapObject(regionMap, (regionName: string, region: Region) =>
96+
leftAlign(region.lines).join('\n'))
9497
};
9598
} else {
9699
return {contents, regions: {}};
97100
}
98101
}
99102

100103
function mapObject(obj: RegionMap, mapper: (regionName: string, region: Region) => string) {
101-
const mappedObj:{[regionName: string]: string} = {};
104+
const mappedObj: {[regionName: string]: string} = {};
102105
Object.keys(obj).forEach((key: string) => { mappedObj[key] = mapper(key, obj[key]); });
103106
return mappedObj;
104107
}

0 commit comments

Comments
 (0)