Skip to content

Commit 487ba06

Browse files
committed
chore: upgrade Prettier
1 parent 4886f9e commit 487ba06

File tree

12 files changed

+94
-61
lines changed

12 files changed

+94
-61
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

babel.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
presets: [
3-
['@babel/preset-env', { targets: { node: 'current' } }],
4-
'@babel/preset-typescript',
3+
["@babel/preset-env", { targets: { node: "current" } }],
4+
"@babel/preset-typescript",
55
],
6-
};
6+
};

docs/rule-jsdoc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ You can set default importability value that applies to the entire project.
138138

139139
For example, i you set the default importability to `package`, any export without JSDoc annotation is treated as `@package`.
140140

141-
You can override this default value by adding JSDoc annotation to the export. To make an export public, add `@public` annotation.
141+
You can override this default value by adding JSDoc annotation to the export. To make an export public, add `@public` annotation.
142142

143143
**Example:**
144144

@@ -149,11 +149,11 @@ You can override this default value by adding JSDoc annotation to the export. To
149149
export const pika = "chu"; // no JSDoc, but automatically applied @package
150150

151151
// ----- sub/foo.ts
152-
// you can import
152+
// you can import
153153
import { pika } from "./bar";
154154

155155
// ----- bar2.ts
156-
// you cannot import because pika is @package
156+
// you cannot import because pika is @package
157157
import { pika } from "./sub/bar`;
158158
```
159159

eslint-local-rules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// for eslint-plugin-local-rules
22
try {
33
// eslint-disable-next-line @typescript-eslint/no-var-requires
4-
module.exports = require('./').rules
4+
module.exports = require("./").rules;
55
// eslint-disable-next-line no-empty
66
} catch (e) {
7-
console.warn(e)
7+
console.warn(e);
88
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"eslint-plugin-local-rules": "^1.1.0",
5757
"espree": "^10.0.1",
5858
"jest": "^29.6.1",
59-
"prettier": "^3.0.0",
59+
"prettier": "^3.2.5",
6060
"typescript": "^5.1.6"
6161
},
6262
"workspaces": [

src/__tests__/directory-structure.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const tester = getESLintTester();
55
describe("directory structure", () => {
66
it("Canot import from subsub directory", async () => {
77
const result = await tester.lintFile(
8-
"src/directory-structure/subsubUser.ts"
8+
"src/directory-structure/subsubUser.ts",
99
);
1010
expect(result).toMatchInlineSnapshot(`
1111
Array [
@@ -25,19 +25,19 @@ Array [
2525
});
2626
it("Can import from sub/index.ts", async () => {
2727
const result = await tester.lintFile(
28-
"src/directory-structure/subIndexUser.ts"
28+
"src/directory-structure/subIndexUser.ts",
2929
);
3030
expect(result).toEqual([]);
3131
});
3232
it("Can import from ../pkg", async () => {
3333
const result = await tester.lintFile(
34-
"src/directory-structure/sub/sub2/parentUser.ts"
34+
"src/directory-structure/sub/sub2/parentUser.ts",
3535
);
3636
expect(result).toEqual([]);
3737
});
3838
it("Cannot import from sibling sub-package", async () => {
3939
const result = await tester.lintFile(
40-
"src/directory-structure/sub/sub3/siblingUser.ts"
40+
"src/directory-structure/sub/sub3/siblingUser.ts",
4141
);
4242
expect(result).toMatchInlineSnapshot(`
4343
Array [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
22
* @package
33
*/
4-
export default "I am bar";
4+
export default "I am bar";

src/__tests__/library.ts

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ const tester = getESLintTester();
55
describe("library", () => {
66
describe("Node.js builtin modules", () => {
77
it("No error with defaultImportability=package ", async () => {
8-
const result = await tester.lintFile("src/library/nodeBuiltinModules.ts", {
9-
jsdoc: {
10-
defaultImportability: "package",
8+
const result = await tester.lintFile(
9+
"src/library/nodeBuiltinModules.ts",
10+
{
11+
jsdoc: {
12+
defaultImportability: "package",
13+
},
1114
},
12-
});
15+
);
1316
expect(result).toMatchInlineSnapshot(`Array []`);
1417
});
1518
});
@@ -24,31 +27,40 @@ describe("library", () => {
2427
});
2528
describe("Entrypoint is missing", () => {
2629
it("No error with defaultImportability=package", async () => {
27-
const result = await tester.lintFile("src/library/thirdPartyModules/missingEntrypoint.ts", {
28-
jsdoc: {
29-
defaultImportability: "package",
30+
const result = await tester.lintFile(
31+
"src/library/thirdPartyModules/missingEntrypoint.ts",
32+
{
33+
jsdoc: {
34+
defaultImportability: "package",
35+
},
3036
},
31-
});
37+
);
3238
expect(result).toMatchInlineSnapshot(`Array []`);
3339
});
3440
});
3541
describe("Importing sub module", () => {
3642
it("No error with defaultImportability=package", async () => {
37-
const result = await tester.lintFile("src/library/thirdPartyModules/hasSubModule.ts", {
38-
jsdoc: {
39-
defaultImportability: "package",
43+
const result = await tester.lintFile(
44+
"src/library/thirdPartyModules/hasSubModule.ts",
45+
{
46+
jsdoc: {
47+
defaultImportability: "package",
48+
},
4049
},
41-
});
50+
);
4251
expect(result).toMatchInlineSnapshot(`Array []`);
4352
});
4453
});
4554
describe("With exports field", () => {
4655
it("No error with defaultImportability=package", async () => {
47-
const result = await tester.lintFile("src/library/thirdPartyModules/withExportsField.ts", {
48-
jsdoc: {
49-
defaultImportability: "package",
56+
const result = await tester.lintFile(
57+
"src/library/thirdPartyModules/withExportsField.ts",
58+
{
59+
jsdoc: {
60+
defaultImportability: "package",
61+
},
5062
},
51-
});
63+
);
5264
expect(result).toMatchInlineSnapshot(`Array []`);
5365
});
5466
});
@@ -64,31 +76,40 @@ describe("library", () => {
6476
});
6577
describe("Entrypoint is missing", () => {
6678
it("No error with defaultImportability=package", async () => {
67-
const result = await tester.lintFile("src/library/workspaceModules/missingEntrypoint.ts", {
68-
jsdoc: {
69-
defaultImportability: "package",
79+
const result = await tester.lintFile(
80+
"src/library/workspaceModules/missingEntrypoint.ts",
81+
{
82+
jsdoc: {
83+
defaultImportability: "package",
84+
},
7085
},
71-
});
86+
);
7287
expect(result).toMatchInlineSnapshot(`Array []`);
7388
});
7489
});
7590
describe("Importing sub module", () => {
7691
it("No error with defaultImportability=package", async () => {
77-
const result = await tester.lintFile("src/library/workspaceModules/hasSubModule.ts", {
78-
jsdoc: {
79-
defaultImportability: "package",
92+
const result = await tester.lintFile(
93+
"src/library/workspaceModules/hasSubModule.ts",
94+
{
95+
jsdoc: {
96+
defaultImportability: "package",
97+
},
8098
},
81-
});
99+
);
82100
expect(result).toMatchInlineSnapshot(`Array []`);
83101
});
84102
});
85103
describe("With exports field", () => {
86104
it("No error with defaultImportability=package", async () => {
87-
const result = await tester.lintFile("src/library/workspaceModules/withExportsField.ts", {
88-
jsdoc: {
89-
defaultImportability: "package",
105+
const result = await tester.lintFile(
106+
"src/library/workspaceModules/withExportsField.ts",
107+
{
108+
jsdoc: {
109+
defaultImportability: "package",
110+
},
90111
},
91-
});
112+
);
92113
expect(result).toMatchInlineSnapshot(`Array []`);
93114
});
94115
});

src/__tests__/reexport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Array [
4545
});
4646
it("Cannot re-export a package-private variable", async () => {
4747
const result = await tester.lintFile(
48-
"src/reexport4/indexLoophole/reexportFromSubFoo.ts"
48+
"src/reexport4/indexLoophole/reexportFromSubFoo.ts",
4949
);
5050
expect(result).toMatchInlineSnapshot(`
5151
Array [
@@ -65,7 +65,7 @@ Array [
6565
});
6666
it("Can re-export a variable exported from index.ts", async () => {
6767
const result = await tester.lintFile(
68-
"src/reexport4/indexLoophole/reexportFromSubIndex.ts"
68+
"src/reexport4/indexLoophole/reexportFromSubIndex.ts",
6969
);
7070
expect(result).toMatchInlineSnapshot(`Array []`);
7171
});
@@ -110,7 +110,7 @@ Array [
110110
jsdoc: {
111111
indexLoophole: false,
112112
},
113-
}
113+
},
114114
);
115115
expect(result).toMatchInlineSnapshot(`
116116
Array [
@@ -161,7 +161,7 @@ Array [
161161
indexLoophole: false,
162162
filenameLoophole: true,
163163
},
164-
}
164+
},
165165
);
166166
expect(result).toMatchInlineSnapshot(`Array []`);
167167
});
@@ -173,7 +173,7 @@ Array [
173173
indexLoophole: false,
174174
filenameLoophole: true,
175175
},
176-
}
176+
},
177177
);
178178
expect(result).toMatchInlineSnapshot(`
179179
Array [

src/core/checkSymbolmportability.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ export function checkSymbolImportability(
3434
return;
3535
}
3636

37-
if (packageOptions.treatSelfReferenceAs === "external" && possibleSubpathImportFromPackage.test(moduleSpecifier)) {
37+
if (
38+
packageOptions.treatSelfReferenceAs === "external" &&
39+
possibleSubpathImportFromPackage.test(moduleSpecifier)
40+
) {
3841
// Check whether this import is the result of a self-reference.
3942
const lookupResult = lookupPackageJson(importerFilename);
4043
if (lookupResult !== null) {
41-
if (checkIfImportIsSelfReference(moduleSpecifier, lookupResult.packageJson.name)) {
44+
if (
45+
checkIfImportIsSelfReference(
46+
moduleSpecifier,
47+
lookupResult.packageJson.name,
48+
)
49+
) {
4250
// This is a self-reference, so treat as external.
4351
return;
4452
}
@@ -92,10 +100,14 @@ export function checkSymbolImportability(
92100
return inPackage ? undefined : "package";
93101
}
94102

95-
const possibleSubpathImportFromPackage = /^(?![./\\])([^/\\]*)(?:$|[/\\][^/\\])/;
103+
const possibleSubpathImportFromPackage =
104+
/^(?![./\\])([^/\\]*)(?:$|[/\\][^/\\])/;
96105

97-
const checkIfImportIsSelfReference = (moduleSpecifier: string, packageName: string) => {
98-
const importIsDefaultModule = moduleSpecifier === packageName
99-
const importIsSubModule = moduleSpecifier.startsWith(`${packageName}/`)
100-
return importIsDefaultModule || importIsSubModule
101-
}
106+
const checkIfImportIsSelfReference = (
107+
moduleSpecifier: string,
108+
packageName: string,
109+
) => {
110+
const importIsDefaultModule = moduleSpecifier === packageName;
111+
const importIsSubModule = moduleSpecifier.startsWith(`${packageName}/`);
112+
return importIsDefaultModule || importIsSubModule;
113+
};

src/utils/getAccessOfJsDocs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type JSDocAccess = "public" | "package" | "private";
77
*/
88
export function getAccessOfJsDocs(
99
tags: readonly Tag[],
10-
defaultImportability: JSDocAccess
10+
defaultImportability: JSDocAccess,
1111
): JSDocAccess {
1212
for (const tag of tags) {
1313
const tagName = tag.name;

0 commit comments

Comments
 (0)