Skip to content

Commit 187566b

Browse files
committed
Prettier
1 parent 82f77ef commit 187566b

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

scripts/makeArrows.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,35 @@ const pathToCombinedTranslationKeys = path.join(
66
'./translationKeys/combined-translation-keys.txt'
77
);
88

9-
const pathToArrowsOut = path.join(
10-
__dirname,
11-
'../src/locales/xx.js'
12-
);
9+
const pathToArrowsOut = path.join(__dirname, '../src/locales/xx.js');
1310

1411
const wordRE = /^[A-Za-z]+$/;
1512

1613
function makeArrows() {
17-
const lines = fs.readFileSync(pathToCombinedTranslationKeys, 'utf-8').split(/\r?\n/);
18-
const entries = lines.map(line => {
19-
const key = line.split(/\/\//)[0].trim();
20-
const escapedKey = key.replace(/\'/g, '\\\'');
21-
const maybeQuoteKey = wordRE.test(key) ? key : '\'' + escapedKey + '\'';
22-
const arrowStr = arrowPad(getArrowLen(key));
23-
24-
return ' ' + maybeQuoteKey + ': \'' + arrowStr + escapedKey + arrowStr + '\'';
25-
}).join(',\n');
26-
14+
const lines = fs
15+
.readFileSync(pathToCombinedTranslationKeys, 'utf-8')
16+
.split(/\r?\n/);
17+
const entries = lines
18+
.map(line => {
19+
const key = line.split(/\/\//)[0].trim();
20+
const escapedKey = key.replace(/\'/g, "\\'");
21+
const maybeQuoteKey = wordRE.test(key) ? key : "'" + escapedKey + "'";
22+
const arrowStr = arrowPad(getArrowLen(key));
23+
24+
return (
25+
' ' + maybeQuoteKey + ": '" + arrowStr + escapedKey + arrowStr + "'"
26+
);
27+
})
28+
.join(',\n');
29+
30+
const ignorePrettier = '/* eslint-disable prettier */';
2731
const head = 'export default {';
2832
const tail = '}';
2933

30-
fs.writeFile(pathToArrowsOut, [head, entries, tail].join('\n'))
34+
fs.writeFile(
35+
pathToArrowsOut,
36+
[ignorePrettier, head, entries, tail].join('\n')
37+
);
3138
console.log('arrows mock translation written to: ' + pathToArrowsOut);
3239
}
3340

@@ -38,7 +45,7 @@ function getArrowLen(key) {
3845

3946
function arrowPad(n) {
4047
let out = '';
41-
for(let i = 0; i < n; i++) {
48+
for (let i = 0; i < n; i++) {
4249
out += '⇚';
4350
}
4451
return out;

src/locales/xx.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prettier */
12
export default {
23
'Anchor Point': '⇚⇚Anchor Point⇚⇚',
34
Angle: '⇚Angle⇚',

0 commit comments

Comments
 (0)