Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
# "At 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
- cron: "0 8 * * 1"

permissions:
contents: read

jobs:
audit:
name: Audit Dependencies
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
required: true
type: string

permissions:
contents: read
checks: write

jobs:
lint-all:
name: Lint All
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"

permissions:
contents: read

jobs:
lint:
name: Lint
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"

permissions:
contents: read

jobs:
analyze:
name: Analyze
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- edited
- synchronize

permissions:
contents: read

jobs:
commitlint:
name: Lint Commits
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
PUBLISH_TOKEN:
required: true

permissions:
contents: read
id-token: write

jobs:
publish:
name: Publish
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ jobs:
if: needs.release.outputs.releases
uses: ./.github/workflows/release-integration.yml
permissions:
contents: read
id-token: write
secrets:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function validate (name) {
errors.push('name length must be greater than zero')
}

if (name.match(/^\./)) {
if (name.startsWith('.')) {
errors.push('name cannot start with a period')
}

Expand Down Expand Up @@ -75,6 +75,11 @@ function validate (name) {
if (nameMatch) {
var user = nameMatch[1]
var pkg = nameMatch[2]

if (pkg.startsWith('.')) {
errors.push('name cannot start with a period')
}

if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
return done(warnings, errors)
}
Expand Down
15 changes: 15 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ test('validate-npm-package-name', function (t) {
validForOldPackages: false,
errors: ['name cannot start with a period'] })

t.same(validate('@npm/.'), {
validForNewPackages: false,
validForOldPackages: false,
errors: ['name cannot start with a period'] })

t.same(validate('@npm/..'), {
validForNewPackages: false,
validForOldPackages: false,
errors: ['name cannot start with a period'] })

t.same(validate('@npm/.package'), {
validForNewPackages: false,
validForOldPackages: false,
errors: ['name cannot start with a period'] })

t.same(validate('_start-with-underscore'), {
validForNewPackages: false,
validForOldPackages: false,
Expand Down