Skip to content

Commit 006ccb2

Browse files
committed
feat: update prettier rules/config
1 parent 99237e3 commit 006ccb2

12 files changed

+45
-35
lines changed

.editorconfig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
root = true
22

3-
[*.js]
4-
indent_size = 2
5-
indent_style = space
3+
[*]
4+
charset = utf-8
65
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
max_line_length = 80
10+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
.DS_Store
2-
node_modules/
2+
._.DS_Store
3+
Thumbs.db
4+
/.env
5+
/.nvm
6+
/.vscode
7+
/npm-debug.log
8+
/yarn.lock
9+
**/node_modules

.prettierignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Ignore artifacts:
1+
.github/
22
*.json
3-
*.xml
4-
*.yml
53
*.md

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "avoid",
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "none",
6+
"proseWrap": "always"
7+
}

.prettierrc.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/update-data-npm.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async function pFilterChunk(chunks, callbackFn, options) {
5656
} else {
5757
const chunk = chunks[i]
5858
const predicateResults = await Promise.all(
59-
chunk.map((value) => {
59+
chunk.map(value => {
6060
if (signal?.aborted) {
6161
return Promise.resolve()
6262
}
@@ -96,7 +96,7 @@ void (async () => {
9696
])
9797
]
9898
const rawLegacyNames = allThePackageNames
99-
.filter((n) => !validateNpmPackageName(n).validForNewPackages)
99+
.filter(n => !validateNpmPackageName(n).validForNewPackages)
100100
.sort(alphanumericComparator)
101101
const seenNames = new Set()
102102
const invalidNames = new Set()
@@ -105,7 +105,7 @@ void (async () => {
105105
await pFilter(
106106
rawLegacyNames,
107107
3,
108-
async (n) => {
108+
async n => {
109109
if (!seenNames.has(n)) {
110110
seenNames.add(n)
111111
spinner.text = `Checking package ${n}...`
@@ -126,7 +126,7 @@ void (async () => {
126126
[
127127
{ json: builtinNames, path: npmBuiltinNamesJsonPath },
128128
{ json: legacyNames, path: npmLegacyNamesJsonPath }
129-
].map((d) =>
129+
].map(d =>
130130
fs.writeFile(d.path, `${JSON.stringify(d.json, null, 2)}\n`, 'utf8')
131131
)
132132
)

src/package-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class PackageURL {
232232
let rawQualifiers
233233
const { searchParams } = url
234234
if (searchParams.size !== 0) {
235-
searchParams.forEach((value) =>
235+
searchParams.forEach(value =>
236236
decodePurlComponent('qualifiers', value)
237237
)
238238
// Split the remainder once from right on '?'.

src/purl-component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ const {
3232
validateSubpath
3333
} = require('./validate')
3434

35-
const PurlComponentEncoder = (comp) =>
35+
const PurlComponentEncoder = comp =>
3636
isNonEmptyString(comp) ? encodeURIComponent(comp) : ''
3737

38-
const PurlComponentStringNormalizer = (comp) =>
38+
const PurlComponentStringNormalizer = comp =>
3939
typeof comp === 'string' ? comp : undefined
4040

4141
const PurlComponentValidator = (_comp, _throws) => true

src/purl-type.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const {
1414
const { validateEmptyByType, validateRequiredByType } = require('./validate')
1515
const { PurlError } = require('./error')
1616

17-
const PurlTypNormalizer = (purl) => purl
17+
const PurlTypNormalizer = purl => purl
1818
const PurlTypeValidator = (_purl, _throws) => true
1919

2020
const getNpmBuiltinNames = (() => {
@@ -48,9 +48,9 @@ function getNpmId(purl) {
4848
return `${namespace?.length > 0 ? `${namespace}/` : ''}${name}`
4949
}
5050

51-
const isNpmBuiltinName = (id) => getNpmBuiltinNames().includes(id.toLowerCase())
51+
const isNpmBuiltinName = id => getNpmBuiltinNames().includes(id.toLowerCase())
5252

53-
const isNpmLegacyName = (id) => getNpmLegacyNames().includes(id)
53+
const isNpmLegacyName = id => getNpmLegacyNames().includes(id)
5454

5555
module.exports = {
5656
// PURL types:

test/benchmark.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { PackageURL } = require('../src/package-url')
77
describe('PackageURL', () => {
88
it('Benchmarking the library', () => {
99
const iterations = 10000
10-
const data = TEST_FILE.filter((obj) => !obj.is_invalid)
10+
const data = TEST_FILE.filter(obj => !obj.is_invalid)
1111
const { length: dataLength } = data
1212
const objects = []
1313
for (let i = 0; i < iterations; i += dataLength) {

test/package-url.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('PackageURL', function () {
9494
}
9595

9696
it('should validate required params', function () {
97-
const testValid = (paramName) => {
97+
const testValid = paramName => {
9898
const paramIndex = paramMap[paramName]
9999
const args = createArgs(paramName, paramName)
100100
const message = JSON.stringify(args[paramIndex])
@@ -106,7 +106,7 @@ describe('PackageURL', function () {
106106
}
107107
}
108108

109-
const testInvalid = (paramName) => {
109+
const testInvalid = paramName => {
110110
const paramIndex = paramMap[paramName]
111111
;[
112112
createArgs(paramName, 0),
@@ -117,7 +117,7 @@ describe('PackageURL', function () {
117117
createArgs(paramName, null),
118118
createArgs(paramName, undefined),
119119
createArgs(paramName, '')
120-
].forEach((args) => {
120+
].forEach(args => {
121121
const message = JSON.stringify(args[paramIndex])
122122
try {
123123
new PackageURL(...args)
@@ -128,21 +128,21 @@ describe('PackageURL', function () {
128128
})
129129
}
130130

131-
;['type', 'name'].forEach((paramName) => {
131+
;['type', 'name'].forEach(paramName => {
132132
testValid(paramName)
133133
testInvalid(paramName)
134134
})
135135
})
136136

137137
it('should validate string params', function () {
138-
const testValid = (paramName) => {
138+
const testValid = paramName => {
139139
const paramIndex = paramMap[paramName]
140140
;[
141141
createArgs(paramName, paramName),
142142
createArgs(paramName, null),
143143
createArgs(paramName, undefined),
144144
createArgs(paramName, '')
145-
].forEach((args) => {
145+
].forEach(args => {
146146
const message = JSON.stringify(args[paramIndex])
147147
try {
148148
new PackageURL(...args)
@@ -153,15 +153,15 @@ describe('PackageURL', function () {
153153
})
154154
}
155155

156-
const testInvalid = (paramName) => {
156+
const testInvalid = paramName => {
157157
const paramIndex = paramMap[paramName]
158158
;[
159159
createArgs(paramName, 0),
160160
createArgs(paramName, false),
161161
createArgs(paramName, 1),
162162
createArgs(paramName, true),
163163
createArgs(paramName, {})
164-
].forEach((args) => {
164+
].forEach(args => {
165165
const message = JSON.stringify(args[paramIndex])
166166
try {
167167
new PackageURL(...args)
@@ -172,7 +172,7 @@ describe('PackageURL', function () {
172172
})
173173
}
174174

175-
;['namespace', 'version', 'subpath'].forEach((paramName) => {
175+
;['namespace', 'version', 'subpath'].forEach(paramName => {
176176
testValid(paramName)
177177
testInvalid(paramName)
178178
})
@@ -223,7 +223,7 @@ describe('PackageURL', function () {
223223

224224
describe('toString()', function () {
225225
it('type is validated', function () {
226-
;['ty#pe', 'ty@pe', 'ty/pe', '1type'].forEach((type) => {
226+
;['ty#pe', 'ty@pe', 'ty/pe', '1type'].forEach(type => {
227227
assert.throws(
228228
() => new PackageURL(type, undefined, 'name'),
229229
/contains an illegal character|cannot start with a number/

0 commit comments

Comments
 (0)