Skip to content

Commit 5a7fbcf

Browse files
feat: adding jsdoc/type-formatting rule (#106)
1 parent 094e382 commit 5a7fbcf

File tree

5 files changed

+157
-98
lines changed

5 files changed

+157
-98
lines changed

configs/typescript.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,13 @@ async function getTypescriptJSDocRecommendedConfig() {
289289
// No need
290290
// "jsdoc/text-escaping": "error",
291291

292-
// TODO enable after https://github.com/gajus/eslint-plugin-jsdoc/issues/1615
293-
// "jsdoc/type-formatting": "error",
292+
"jsdoc/type-formatting": [
293+
"error",
294+
{
295+
objectTypeBracketSpacing: " ",
296+
objectFieldSeparator: "comma-and-linebreak",
297+
},
298+
],
294299

295300
// Doesn't support function overloading/tuples/`readonly`/module keyword/etc
296301
// Also `typescript` reports this itself

configs/utils/get-json-file.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Cache {
1414
/**
1515
* Get the cached value of the given key.
1616
* @param {string} key The key to get.
17-
* @returns {import('type-fest').JsonObject} The cached value or null.
17+
* @returns {import("type-fest").JsonObject} The cached value or null.
1818
*/
1919
get(key) {
2020
const entry = this.map.get(key);
@@ -33,7 +33,7 @@ class Cache {
3333
/**
3434
* Set the value of the given key.
3535
* @param {string} key The key to set.
36-
* @param {import('type-fest').JsonObject} value The value to set.
36+
* @param {import("type-fest").JsonObject} value The value to set.
3737
* @returns {void}
3838
*/
3939
set(key, value) {
@@ -57,7 +57,7 @@ const cache = new Cache();
5757
* Don't cache the data.
5858
* @param {string} dir The path to a directory to read.
5959
* @param {string} filename The filename.
60-
* @returns {import('type-fest').JsonObject|null} The read `package.json` data, or null.
60+
* @returns {import("type-fest").JsonObject | null} The read `package.json` data, or null.
6161
*/
6262
function readJsonFile(dir, filename) {
6363
const filePath = path.join(dir, filename);
@@ -86,7 +86,7 @@ function readJsonFile(dir, filename) {
8686
* The data is cached if found, then it's used after.
8787
* @param {string} filename The filename.
8888
* @param {string=} startPath A file path to lookup.
89-
* @returns {import('type-fest').JsonObject | null} A found `package.json` data or `null`.
89+
* @returns {import("type-fest").JsonObject | null} A found `package.json` data or `null`.
9090
* This object have additional property `filePath`.
9191
*/
9292
function getJsonFile(filename, startPath = "a.js") {

0 commit comments

Comments
 (0)