Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update prettier rules/config #81

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
root = true

[*.js]
indent_size = 2
indent_style = space
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.DS_Store
node_modules/
._.DS_Store
Thumbs.db
/.env
/.nvm
/.vscode
/npm-debug.log
/yarn.lock
**/node_modules
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Ignore artifacts:
.github/
*.json
*.xml
*.yml
*.md
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"proseWrap": "always"
}
7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class PackageURL {
let rawQualifiers
const { searchParams } = url
if (searchParams.size !== 0) {
searchParams.forEach((value) =>
searchParams.forEach(value =>
decodePurlComponent('qualifiers', value)
)
// Split the remainder once from right on '?'.
Expand Down
4 changes: 2 additions & 2 deletions src/purl-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const {
validateSubpath
} = require('./validate')

const PurlComponentEncoder = (comp) =>
const PurlComponentEncoder = comp =>
isNonEmptyString(comp) ? encodeURIComponent(comp) : ''

const PurlComponentStringNormalizer = (comp) =>
const PurlComponentStringNormalizer = comp =>
typeof comp === 'string' ? comp : undefined

const PurlComponentValidator = (_comp, _throws) => true
Expand Down
2 changes: 1 addition & 1 deletion src/purl-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
const { validateEmptyByType, validateRequiredByType } = require('./validate')
const { PurlError } = require('./error')

const PurlTypNormalizer = (purl) => purl
const PurlTypNormalizer = purl => purl

const PurlTypeValidator = (_purl, _throws) => true

Expand Down
2 changes: 1 addition & 1 deletion test/benchmark.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { PackageURL } = require('../src/package-url')
describe('PackageURL', () => {
it('Benchmarking the library', () => {
const iterations = 10000
const data = TEST_FILE.filter((obj) => !obj.is_invalid)
const data = TEST_FILE.filter(obj => !obj.is_invalid)
const { length: dataLength } = data
const objects = []
for (let i = 0; i < iterations; i += dataLength) {
Expand Down
20 changes: 10 additions & 10 deletions test/package-url.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('PackageURL', function () {
}

it('should validate required params', function () {
const testValid = (paramName) => {
const testValid = paramName => {
const paramIndex = paramMap[paramName]
const args = createArgs(paramName, paramName)
const message = JSON.stringify(args[paramIndex])
Expand All @@ -98,7 +98,7 @@ describe('PackageURL', function () {
}
}

const testInvalid = (paramName) => {
const testInvalid = paramName => {
const paramIndex = paramMap[paramName]
;[
createArgs(paramName, 0),
Expand All @@ -109,7 +109,7 @@ describe('PackageURL', function () {
createArgs(paramName, null),
createArgs(paramName, undefined),
createArgs(paramName, '')
].forEach((args) => {
].forEach(args => {
const message = JSON.stringify(args[paramIndex])
try {
new PackageURL(...args)
Expand All @@ -120,21 +120,21 @@ describe('PackageURL', function () {
})
}

;['type', 'name'].forEach((paramName) => {
;['type', 'name'].forEach(paramName => {
testValid(paramName)
testInvalid(paramName)
})
})

it('should validate string params', function () {
const testValid = (paramName) => {
const testValid = paramName => {
const paramIndex = paramMap[paramName]
;[
createArgs(paramName, paramName),
createArgs(paramName, null),
createArgs(paramName, undefined),
createArgs(paramName, '')
].forEach((args) => {
].forEach(args => {
const message = JSON.stringify(args[paramIndex])
try {
new PackageURL(...args)
Expand All @@ -145,15 +145,15 @@ describe('PackageURL', function () {
})
}

const testInvalid = (paramName) => {
const testInvalid = paramName => {
const paramIndex = paramMap[paramName]
;[
createArgs(paramName, 0),
createArgs(paramName, false),
createArgs(paramName, 1),
createArgs(paramName, true),
createArgs(paramName, {})
].forEach((args) => {
].forEach(args => {
const message = JSON.stringify(args[paramIndex])
try {
new PackageURL(...args)
Expand All @@ -164,7 +164,7 @@ describe('PackageURL', function () {
})
}

;['namespace', 'version', 'subpath'].forEach((paramName) => {
;['namespace', 'version', 'subpath'].forEach(paramName => {
testValid(paramName)
testInvalid(paramName)
})
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('PackageURL', function () {

describe('toString()', function () {
it('type is validated', function () {
;['ty#pe', 'ty@pe', 'ty/pe', '1type'].forEach((type) => {
;['ty#pe', 'ty@pe', 'ty/pe', '1type'].forEach(type => {
assert.throws(
() => new PackageURL(type, undefined, 'name'),
/contains an illegal character|cannot start with a number/
Expand Down
Loading