Skip to content

Commit 6460d2a

Browse files
authored
Merge pull request #95 from assetgraph/depfu/update/npm/prettier-3.0.0
Update prettier → 3.0.0 (unknown)
2 parents 2ef5ec9 + 1f238e8 commit 6460d2a

18 files changed

+387
-356
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Tests
55

66
jobs:
77
test:
8-
runs-on: ubuntu-18.04
8+
runs-on: ubuntu-latest
99
name: Node ${{ matrix.node }}
1010
strategy:
1111
matrix:
@@ -23,7 +23,7 @@ jobs:
2323
- run: npm test
2424

2525
test-targets:
26-
runs-on: ubuntu-18.04
26+
runs-on: ubuntu-latest
2727
name: ${{ matrix.targets.name }}
2828
strategy:
2929
matrix:

bin/applyBabelJob.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const urlTools = require('urltools');
1313

1414
const commandLineOptions = require('optimist')
1515
.usage(
16-
'$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...'
16+
'$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...',
1717
)
1818
.options('defaultlocale', {
1919
describe:
@@ -33,8 +33,8 @@ const localeIds =
3333
commandLineOptions.locales &&
3434
_.flatten(
3535
_.flatten([commandLineOptions.locales]).map((localeId) =>
36-
localeId.split(',')
37-
)
36+
localeId.split(','),
37+
),
3838
).map(i18nTools.normalizeLocaleId);
3939

4040
const initialAssetUrls = commandLineOptions._.map(urlTools.fsFilePathToFileUrl);
@@ -44,13 +44,13 @@ let i18nUrl;
4444

4545
if (commandLineOptions.defaultlocale) {
4646
defaultLocaleId = i18nTools.normalizeLocaleId(
47-
commandLineOptions.defaultlocale
47+
commandLineOptions.defaultlocale,
4848
);
4949
if (localeIds && localeIds.indexOf(defaultLocaleId) === -1) {
5050
throw new Error(
5151
`The default locale id (${defaultLocaleId}) is not among the locales listed with the --locales switch (${localeIds.join(
52-
', '
53-
)})`
52+
', ',
53+
)})`,
5454
);
5555
}
5656
} else if (localeIds) {
@@ -108,7 +108,7 @@ if (commandLineOptions.i18n) {
108108

109109
const occurrencesByKey = i18nTools.findOccurrences(
110110
assetGraph,
111-
assetGraph.findAssets({ type: 'Html', isInitial: true })
111+
assetGraph.findAssets({ type: 'Html', isInitial: true }),
112112
);
113113

114114
let i18nAssetForAllKeys;
@@ -124,7 +124,7 @@ if (commandLineOptions.i18n) {
124124
assetGraph.addAsset(i18nAssetForAllKeys);
125125
assetGraph.emit(
126126
'info',
127-
`--i18n ${commandLineOptions.i18n} not found, creating it`
127+
`--i18n ${commandLineOptions.i18n} not found, creating it`,
128128
);
129129
} else if (!i18nAssetForAllKeys.isLoaded) {
130130
i18nAssetForAllKeys.parseTree = {};
@@ -143,14 +143,14 @@ if (commandLineOptions.i18n) {
143143

144144
const babelBody = fs.readFileSync(
145145
path.resolve(commandLineOptions.babeldir, fileName),
146-
'utf-8'
146+
'utf-8',
147147
);
148148

149149
isSeenByLocaleId[localeId] = true;
150150

151151
if (localeIds && localeIds.indexOf(localeId) === -1) {
152152
console.warn(
153-
`Skipping ${fileName} because ${localeId} was not mentioned in --locales`
153+
`Skipping ${fileName} because ${localeId} was not mentioned in --locales`,
154154
);
155155
return;
156156
}
@@ -192,7 +192,7 @@ if (commandLineOptions.i18n) {
192192
throw new Error(
193193
`Error: Expected ${JSON.stringify(cursor)}['${
194194
path[0]
195-
}'] to be undefined or an array while processing line ${lineNumber} of ${fileName}:\n${line}`
195+
}'] to be undefined or an array while processing line ${lineNumber} of ${fileName}:\n${line}`,
196196
);
197197
}
198198
} else {
@@ -206,30 +206,30 @@ if (commandLineOptions.i18n) {
206206
throw new Error(
207207
`Error: Expected ${JSON.stringify(cursor)}['${
208208
path[0]
209-
}'] to be undefined or an object while processing line ${lineNumber} of ${fileName}:\n${line}`
209+
}'] to be undefined or an object while processing line ${lineNumber} of ${fileName}:\n${line}`,
210210
);
211211
}
212212
}
213213
cursor = cursor[path.shift()];
214214
}
215215
if (path[0] in cursor) {
216216
throw new Error(
217-
`Error: Found double declaration of key in line ${lineNumber} of ${fileName}:\n${line}`
217+
`Error: Found double declaration of key in line ${lineNumber} of ${fileName}:\n${line}`,
218218
);
219219
}
220220
cursor[path[0]] = value;
221221
} else {
222222
console.warn(
223223
`Couldn't parse line ${
224224
lineNumber + 1
225-
} of the ${localeId} file: ${line}`
225+
} of the ${localeId} file: ${line}`,
226226
);
227227
}
228228
}
229229
});
230230
} else {
231231
console.warn(
232-
`Skipping file whose basename does not look like a locale id: ${fileName}`
232+
`Skipping file whose basename does not look like a locale id: ${fileName}`,
233233
);
234234
}
235235
}
@@ -238,7 +238,7 @@ if (commandLineOptions.i18n) {
238238
localeIds.forEach((localeId) => {
239239
if (!isSeenByLocaleId[localeId]) {
240240
console.warn(
241-
`${localeId}.txt was not found although --locales ${localeId} was specified`
241+
`${localeId}.txt was not found although --locales ${localeId} was specified`,
242242
);
243243
}
244244
});
@@ -266,7 +266,7 @@ if (commandLineOptions.i18n) {
266266
keys.every(
267267
(key) =>
268268
['zero', 'one', 'two', 'few', 'many', 'other'].indexOf(key) !==
269-
-1
269+
-1,
270270
)
271271
) {
272272
keys = [];
@@ -279,7 +279,7 @@ if (commandLineOptions.i18n) {
279279
`${key}: Discarding plural forms not used in ${localeId}:`,
280280
obj,
281281
'=>',
282-
coalescedObj
282+
coalescedObj,
283283
);
284284
}
285285
obj = coalescedObj;
@@ -336,8 +336,8 @@ if (commandLineOptions.i18n) {
336336
_.merge(
337337
Array.isArray(newTranslation) ? [] : {},
338338
existingTranslation,
339-
newTranslation
340-
)
339+
newTranslation,
340+
),
341341
);
342342
} else if (
343343
typeof existingTranslation === 'undefined' ||
@@ -404,7 +404,7 @@ if (commandLineOptions.i18n) {
404404
if (
405405
!_.isEqual(
406406
occurrence.defaultValue,
407-
allKeysInDefaultLocale[occurrence.key]
407+
allKeysInDefaultLocale[occurrence.key],
408408
)
409409
) {
410410
if (occurrence.type === 'TR' || occurrence.type === 'TRPAT') {
@@ -413,9 +413,9 @@ if (commandLineOptions.i18n) {
413413
const replaceRegExp = new RegExp(
414414
`(TR(?:PAT)?\\((['"])${key.replace(
415415
/[.[\]*+?{}()^$]/g,
416-
'\\$&'
416+
'\\$&',
417417
)}\\2\\s*,\\s*)(?:[^)'"]*|"[^"]*"|'[^']*')*?\\)`,
418-
'g'
418+
'g',
419419
);
420420

421421
replacedTextByAssetId[asset.id] = (
@@ -425,8 +425,8 @@ if (commandLineOptions.i18n) {
425425
).replace(
426426
replaceRegExp,
427427
`$1${util.inspect(
428-
translationsByKeyAndLocaleId[key][defaultLocaleId]
429-
)})`
428+
translationsByKeyAndLocaleId[key][defaultLocaleId],
429+
)})`,
430430
);
431431
}
432432
}
@@ -446,7 +446,7 @@ if (commandLineOptions.i18n) {
446446
$0
447447
.replace(/&lt;/g, '<')
448448
.replace(/&gt;/g, '>')
449-
.replace(/&amp;/g, '&')
449+
.replace(/&amp;/g, '&'),
450450
);
451451
}
452452
asset._rawSrc = replacedText.toString('utf-8');

bin/checkLanguageKeys.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ const localeIds =
5656
commandLineOptions.locales &&
5757
_.flatten(
5858
_.flatten([commandLineOptions.locales]).map((localeId) =>
59-
localeId.split(',')
60-
)
59+
localeId.split(','),
60+
),
6161
).map(i18nTools.normalizeLocaleId);
6262

6363
const defaultLocaleId =
@@ -68,43 +68,43 @@ const ignoreMessageTypes =
6868
commandLineOptions.ignore &&
6969
_.flatten(
7070
_.flatten([commandLineOptions.ignore]).map((ignoreMessageType) =>
71-
ignoreMessageType.split(',')
72-
)
71+
ignoreMessageType.split(','),
72+
),
7373
);
7474

7575
const warnMessageTypes =
7676
commandLineOptions.warn &&
7777
_.flatten(
7878
_.flatten([commandLineOptions.warn]).map((warnMessageType) =>
79-
warnMessageType.split(',')
80-
)
79+
warnMessageType.split(','),
80+
),
8181
);
8282

8383
const includeAttributeNames =
8484
commandLineOptions.includeattribute &&
8585
_.flatten(
8686
_.flatten([commandLineOptions.includeattribute]).map((attributeName) =>
87-
attributeName.split(',')
88-
)
87+
attributeName.split(','),
88+
),
8989
);
9090

9191
const excludeAttributeNames =
9292
commandLineOptions.excludeattribute &&
9393
_.flatten(
9494
_.flatten([commandLineOptions.excludeattribute]).map((attributeName) =>
95-
attributeName.split(',')
96-
)
95+
attributeName.split(','),
96+
),
9797
);
9898

9999
let inputUrls;
100100

101101
if (commandLineOptions._.length > 0) {
102102
inputUrls = commandLineOptions._.map((urlOrFsPath) =>
103-
urlTools.urlOrFsPathToUrl(urlOrFsPath, false)
103+
urlTools.urlOrFsPathToUrl(urlOrFsPath, false),
104104
);
105105
if (!rootUrl) {
106106
rootUrl = urlTools.findCommonUrlPrefix(
107-
inputUrls.filter((inputUrl) => /^file:/.test(inputUrl))
107+
inputUrls.filter((inputUrl) => /^file:/.test(inputUrl)),
108108
);
109109
if (rootUrl) {
110110
console.warn(`Guessing --root from input files: ${rootUrl}`);
@@ -115,7 +115,7 @@ if (commandLineOptions._.length > 0) {
115115
console.warn(`No input files specified, defaulting to ${inputUrls[0]}`);
116116
} else {
117117
throw new Error(
118-
"No input files and no --root specified (or it isn't file:), cannot proceed"
118+
"No input files and no --root specified (or it isn't file:), cannot proceed",
119119
);
120120
}
121121

0 commit comments

Comments
 (0)