Skip to content

Commit 6dc12af

Browse files
committed
chore(linting): lint added files
1 parent db243b6 commit 6dc12af

File tree

4 files changed

+95
-95
lines changed

4 files changed

+95
-95
lines changed

.eslintignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
**/__testfixtures__/*
22
coverage
33
test
4-
docs
5-
.cz-config.js
6-
/build/**
7-
commitlint.config.js
4+
docs

build/changelog-generator/index.js

Lines changed: 71 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
55
* Based on: https://github.com/GoogleChrome/lighthouse/blob/master/build/changelog-generator/
66
*/
7-
'use strict';
8-
const readFileSync = require('fs').readFileSync;
9-
const resolve = require('path').resolve;
10-
const mainTemplate = readFileSync(resolve(__dirname, 'templates/template.hbs')).toString();
11-
const headerPartial = readFileSync(resolve(__dirname, 'templates/header.hbs')).toString();
12-
const commitPartial = readFileSync(resolve(__dirname, 'templates/commit.hbs')).toString();
7+
"use strict";
8+
const readFileSync = require("fs").readFileSync;
9+
const resolve = require("path").resolve;
10+
const mainTemplate = readFileSync(
11+
resolve(__dirname, "templates/template.hbs")
12+
).toString();
13+
const headerPartial = readFileSync(
14+
resolve(__dirname, "templates/header.hbs")
15+
).toString();
16+
const commitPartial = readFileSync(
17+
resolve(__dirname, "templates/commit.hbs")
18+
).toString();
1319

1420
const pullRequestRegex = /\(#(\d+)\)$/;
1521
const parserOpts = {
16-
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
17-
headerCorrespondence: [
18-
'type',
19-
'scope',
20-
'message',
21-
],
22+
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
23+
headerCorrespondence: ["type", "scope", "message"]
2224
};
2325

2426
process.stderr.write(`
@@ -28,70 +30,71 @@ process.stderr.write(`
2830
`);
2931

3032
const writerOpts = {
31-
mainTemplate,
32-
headerPartial,
33-
commitPartial,
34-
transform: commit => {
35-
if (typeof commit.hash === 'string') {
36-
commit.hash = commit.hash.substring(0, 7);
37-
}
33+
mainTemplate,
34+
headerPartial,
35+
commitPartial,
36+
transform: commit => {
37+
if (typeof commit.hash === "string") {
38+
commit.hash = commit.hash.substring(0, 7);
39+
}
3840

39-
if (commit.type === 'test') {
40-
commit.type = 'tests';
41-
} else if (commit.type === 'cli') {
42-
commit.type = 'CLI';
43-
} else if (commit.type === 'new_feature') {
44-
commit.type = 'New Features';
45-
}
41+
if (commit.type === "test") {
42+
commit.type = "tests";
43+
} else if (commit.type === "cli") {
44+
commit.type = "CLI";
45+
} else if (commit.type === "new_feature") {
46+
commit.type = "New Features";
47+
}
4648

47-
if (commit.type) {
48-
commit.type = commit.type.replace(/_/g, ' ');
49-
commit.type = commit.type.substring(0, 1).toUpperCase() + commit.type.substring(1);
50-
} else {
51-
commit.type = 'Misc';
52-
}
49+
if (commit.type) {
50+
commit.type = commit.type.replace(/_/g, " ");
51+
commit.type =
52+
commit.type.substring(0, 1).toUpperCase() + commit.type.substring(1);
53+
} else {
54+
commit.type = "Misc";
55+
}
5356

54-
let pullRequestMatch = commit.header.match(pullRequestRegex);
55-
// if header does not provide a PR we try the message
56-
if (!pullRequestMatch && commit.message) {
57-
pullRequestMatch = commit.message.match(pullRequestRegex);
58-
}
57+
let pullRequestMatch = commit.header.match(pullRequestRegex);
58+
// if header does not provide a PR we try the message
59+
if (!pullRequestMatch && commit.message) {
60+
pullRequestMatch = commit.message.match(pullRequestRegex);
61+
}
5962

60-
if (pullRequestMatch) {
61-
commit.header = commit.header.replace(pullRequestMatch[0], '').trim();
62-
if (commit.message) {
63-
commit.message = commit.message.replace(pullRequestMatch[0], '').trim();
64-
}
63+
if (pullRequestMatch) {
64+
commit.header = commit.header.replace(pullRequestMatch[0], "").trim();
65+
if (commit.message) {
66+
commit.message = commit.message.replace(pullRequestMatch[0], "").trim();
67+
}
6568

66-
commit.PR = pullRequestMatch[1];
67-
}
69+
commit.PR = pullRequestMatch[1];
70+
}
6871

69-
return commit;
70-
},
71-
groupBy: 'type',
72-
commitGroupsSort: (a, b) => {
73-
// put new feature on the top
74-
if (a.title === 'New Features') {
75-
return -1;
76-
}
77-
if (b.title === 'New Features') {
78-
return 1;
79-
}
72+
return commit;
73+
},
74+
groupBy: "type",
75+
commitGroupsSort: (a, b) => {
76+
// put new feature on the top
77+
if (a.title === "New Features") {
78+
return -1;
79+
}
80+
if (b.title === "New Features") {
81+
return 1;
82+
}
8083

81-
// put misc on the bottom
82-
if (a.title === 'Misc') {
83-
return 1;
84-
}
85-
if (b.title === 'Misc') {
86-
return -1;
87-
}
84+
// put misc on the bottom
85+
if (a.title === "Misc") {
86+
return 1;
87+
}
88+
if (b.title === "Misc") {
89+
return -1;
90+
}
8891

89-
return a.title.localeCompare(b.title);
90-
},
91-
commitsSort: ['type', 'scope'],
92+
return a.title.localeCompare(b.title);
93+
},
94+
commitsSort: ["type", "scope"]
9295
};
9396

9497
module.exports = {
95-
writerOpts,
96-
parserOpts,
97-
};
98+
writerOpts,
99+
parserOpts
100+
};

commitlint.config.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
44
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
55
*/
6-
7-
// Config from https://github.com/GoogleChrome/lighthouse/blob/master/commitlint.config.js
8-
'use strict';
6+
// Config from https://github.com/GoogleChrome/lighthouse/blob/master/commitlint.config.js
7+
"use strict";
98

109
module.exports = {
11-
extends: ['cz'],
12-
rules: {
13-
'body-leading-blank': [1, 'always'],
14-
'body-tense': [1, 'always', ['present-imperative']],
15-
'footer-leading-blank': [1, 'always'],
16-
'footer-tense': [1, 'always', ['present-imperative']],
17-
'header-max-length': [2, 'always', 80],
18-
'lang': [0, 'always', 'eng'],
19-
'scope-case': [2, 'always', 'lowerCase'],
20-
'scope-empty': [0, 'never'],
21-
'subject-case': [1, 'always', 'lowerCase'],
22-
'subject-empty': [0, 'never'],
23-
'subject-full-stop': [2, 'never', '.'],
24-
'subject-tense': [1, 'always', ['present-imperative']],
25-
'type-case': [2, 'always', 'lowerCase'],
26-
'type-empty': [2, 'never'],
27-
// The scope-enum : defined in the cz-config
28-
// The 'type-enum': defined in the cz-config
29-
},
30-
};
10+
extends: ["cz"],
11+
rules: {
12+
"body-leading-blank": [1, "always"],
13+
"body-tense": [1, "always", ["present-imperative"]],
14+
"footer-leading-blank": [1, "always"],
15+
"footer-tense": [1, "always", ["present-imperative"]],
16+
"header-max-length": [2, "always", 80],
17+
lang: [0, "always", "eng"],
18+
"scope-case": [2, "always", "lowerCase"],
19+
"scope-empty": [0, "never"],
20+
"subject-case": [1, "always", "lowerCase"],
21+
"subject-empty": [0, "never"],
22+
"subject-full-stop": [2, "never", "."],
23+
"subject-tense": [1, "always", ["present-imperative"]],
24+
"type-case": [2, "always", "lowerCase"],
25+
"type-empty": [2, "never"]
26+
// The scope-enum : defined in the cz-config
27+
// The 'type-enum': defined in the cz-config
28+
}
29+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"scripts": {
1919
"lint": "eslint \"**/*.js\"",
20+
"f":"prettier-eslint \"build/changelog-generator/index.js\" --write",
2021
"format": "prettier-eslint \"bin/**/*.js\" \"lib/**/*.js\" \"test/**/*.js\" --write",
2122
"lint:codeOnly": "eslint \"{lib,bin}/**/!(__testfixtures__)/*.js\" \"{lib,bin}/**.js\"",
2223
"precommit": "lint-staged",

0 commit comments

Comments
 (0)