Skip to content

Commit

Permalink
Fix precede typo
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Jul 2, 2023
1 parent ee47bad commit f2bc104
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type Message =
>
| BaseMessage<'EXPORTS_TYPES_SHOULD_BE_FIRST'>
| BaseMessage<
'EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE',
'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE',
{ conditions: string[] }
>
| BaseMessage<'EXPORTS_DEFAULT_SHOULD_BE_LAST'>
Expand Down
4 changes: 2 additions & 2 deletions pkg/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export async function publint({ pkgDir, vfs, level, strict, _packedFiles }) {
}
}

// a 'module' export should always preceed 'import' or 'require'
// a 'module' export should always precede 'import' or 'require'
if ('module' in exports) {
const conditions = []
if (
Expand All @@ -511,7 +511,7 @@ export async function publint({ pkgDir, vfs, level, strict, _packedFiles }) {

if (conditions.length > 0) {
messages.push({
code: 'EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE',
code: 'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE',
args: { conditions },
path: currentPath.concat('module'),
type: 'error'
Expand Down
2 changes: 1 addition & 1 deletion pkg/src/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function printMessage(m, pkg) {
case 'EXPORTS_TYPES_SHOULD_BE_FIRST':
// prettier-ignore
return `${c.bold(fp(m.path))} should be the first in the object as required by TypeScript.`
case 'EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE': {
case 'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE': {
let conditions = `the ${m.args.conditions
.map((cond) => `"${c.bold(cond)}"`)
.join(' and ')} condition`
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ testFixture('missing-files', [

testFixture('no-exports-module', [])

testFixture('exports-module', ['EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE'])
testFixture('exports-module', ['EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE'])

testFixture('publish-config', ['USE_EXPORTS_BROWSER', 'FILE_DOES_NOT_EXIST'])

Expand Down
2 changes: 1 addition & 1 deletion site/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ If the `"exports"` field contains glob paths, but it doesn't match any files, re

The `"exports"` field should not have globs defined with trailing slashes. It is [deprecated](https://nodejs.org/docs/latest-v16.x/api/packages.html#subpath-folder-mappings) and should use [subpath patterns](https://nodejs.org/api/packages.html#subpath-patterns), e.g. a trailing `/*` instead.

## `EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE`
## `EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE`

Ensure the `"module"` condition comes before the `"import"` and `"require"` conditions. Due to the way conditions are matched top-to-bottom, the `"module"` condition (used in bundler contexts only) must come before an `"import"` or `"require"` condition, so it has the opportunity to take precedence.

Expand Down
2 changes: 1 addition & 1 deletion site/src/utils/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function messageToString(m, pkg) {
case 'EXPORTS_TYPES_SHOULD_BE_FIRST':
// prettier-ignore
return `Should be the first in the object as required by TypeScript.`
case 'EXPORTS_MODULE_SHOULD_PRECEED_IMPORT_REQUIRE': {
case 'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE': {
let conditions = `the ${m.args.conditions
.map((cond) => `"${bold(cond)}"`)
.join(' and ')} condition`
Expand Down

0 comments on commit f2bc104

Please sign in to comment.