Skip to content

Commit 051ac1d

Browse files
committed
Configure & use Prettier for code formatting
1 parent 730415d commit 051ac1d

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path')
55

66
// expected to follow the pattern baseName_language[_script]_country_variant.properties
77
// source: https://docs.oracle.com/javase/9/docs/api/java/util/ResourceBundle.html#getBundle-java.lang.String-java.util.Locale-java.lang.ClassLoader-
8-
function localeFromResourcePath (resourcePath, pathSep, defaultLocale) {
8+
function localeFromResourcePath(resourcePath, pathSep, defaultLocale) {
99
const parts = path.basename(resourcePath).split(pathSep)
1010
const locale = parts[1] && parts[1].replace(/\..*$/, '').toLowerCase()
1111
if (locale === 'pt-pt' || (locale === 'pt' && /^pt/i.test(parts[2]))) {
@@ -15,11 +15,16 @@ function localeFromResourcePath (resourcePath, pathSep, defaultLocale) {
1515
return /^[a-z]{2,3}$/.test(locale || '') ? locale : defaultLocale
1616
}
1717

18-
module.exports = function (content) {
19-
const { biDiSupport, defaultLocale, encoding, keyPath, pathSep } = loaderUtils.getOptions(this) || {}
18+
module.exports = function(content) {
19+
const { biDiSupport, defaultLocale, encoding, keyPath, pathSep } =
20+
loaderUtils.getOptions(this) || {}
2021
const input = content.toString(encoding || 'latin1')
2122
const translations = parse(input, keyPath || false)
22-
const locale = localeFromResourcePath(this.resourcePath, pathSep || '_', defaultLocale || 'en')
23+
const locale = localeFromResourcePath(
24+
this.resourcePath,
25+
pathSep || '_',
26+
defaultLocale || 'en'
27+
)
2328
const mf = new MessageFormat(locale)
2429
if (biDiSupport) mf.setBiDiSupport()
2530
return mf.compile(translations).toString('module.exports')

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@
2525
},
2626
"peerDependencies": {
2727
"messageformat": "1.x | 2.x"
28+
},
29+
"prettier": {
30+
"trailingComma": "none",
31+
"semi": false,
32+
"singleQuote": true
2833
}
2934
}

0 commit comments

Comments
 (0)