Skip to content

Commit 1cf93b5

Browse files
authored
fix(type-formatting): remove propertyIndent option; fixes #1524 (#1525)
This option was particularly problematic in type contexts
1 parent 8c270b3 commit 1cf93b5

File tree

4 files changed

+96
-117
lines changed

4 files changed

+96
-117
lines changed

.README/rules/type-formatting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Determines the spacing to add to unions (`|`). Defaults to a single space (`" "`
8989
|Tags|`param`, `property`, `returns`, `this`, `throws`, `type`, `typedef`, `yields`|
9090
|Recommended|false|
9191
|Settings|`mode`|
92-
|Options|`arrayBrackets`, `enableFixer`, `genericDot`, `objectFieldIndent`, `objectFieldQuote`, `objectFieldSeparator`, `objectFieldSeparatorOptionalLinebreak`, `objectFieldSeparatorTrailingPunctuation`, `propertyQuotes`, `separatorForSingleObjectField`, `stringQuotes`, `typeBracketSpacing`, `unionSpacing`|
92+
|Options|`arrayBrackets`, `enableFixer`, `genericDot`, `objectFieldIndent`, `objectFieldQuote`, `objectFieldSeparator`, `objectFieldSeparatorOptionalLinebreak`, `objectFieldSeparatorTrailingPunctuation`, `separatorForSingleObjectField`, `stringQuotes`, `typeBracketSpacing`, `unionSpacing`|
9393

9494
## Failing examples
9595

docs/rules/type-formatting.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Determines the spacing to add to unions (`|`). Defaults to a single space (`" "`
119119
|Tags|`param`, `property`, `returns`, `this`, `throws`, `type`, `typedef`, `yields`|
120120
|Recommended|false|
121121
|Settings|`mode`|
122-
|Options|`arrayBrackets`, `enableFixer`, `genericDot`, `objectFieldIndent`, `objectFieldQuote`, `objectFieldSeparator`, `objectFieldSeparatorOptionalLinebreak`, `objectFieldSeparatorTrailingPunctuation`, `propertyQuotes`, `separatorForSingleObjectField`, `stringQuotes`, `typeBracketSpacing`, `unionSpacing`|
122+
|Options|`arrayBrackets`, `enableFixer`, `genericDot`, `objectFieldIndent`, `objectFieldQuote`, `objectFieldSeparator`, `objectFieldSeparatorOptionalLinebreak`, `objectFieldSeparatorTrailingPunctuation`, `separatorForSingleObjectField`, `stringQuotes`, `typeBracketSpacing`, `unionSpacing`|
123123

124124
<a name="user-content-type-formatting-failing-examples"></a>
125125
<a name="type-formatting-failing-examples"></a>
@@ -204,12 +204,6 @@ The following patterns are considered problems:
204204
*/
205205
// Message: Inconsistent object field quotes null
206206

207-
/**
208-
* @param {ab.cd.ef} cfg
209-
*/
210-
// "jsdoc/type-formatting": ["error"|"warn", {"propertyQuotes":"double"}]
211-
// Message: Inconsistent double property quotes usage
212-
213207
/**
214208
* @param {{a: string}} cfg A long
215209
* description
@@ -285,12 +279,6 @@ The following patterns are considered problems:
285279
// "jsdoc/type-formatting": ["error"|"warn", {"typeBracketSpacing":""}]
286280
// Message: Must have no initial spacing
287281

288-
/**
289-
* @param {ab."cd".ef} cfg
290-
*/
291-
// "jsdoc/type-formatting": ["error"|"warn", {"propertyQuotes":null}]
292-
// Message: Inconsistent null property quotes usage
293-
294282
/**
295283
* @param {{a: string, b: number}} cfg
296284
*/
@@ -358,16 +346,6 @@ The following patterns are not considered problems:
358346
*/
359347
// "jsdoc/type-formatting": ["error"|"warn", {"objectFieldQuote":"double"}]
360348

361-
/**
362-
* @param {ab.cd.ef} cfg
363-
*/
364-
// "jsdoc/type-formatting": ["error"|"warn", {"propertyQuotes":null}]
365-
366-
/**
367-
* @param {ab."cd ef".gh} cfg
368-
*/
369-
// "jsdoc/type-formatting": ["error"|"warn", {"propertyQuotes":null}]
370-
371349
/**
372350
* @param {ab | cd} cfg
373351
*/

src/rules/typeFormatting.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default iterateJsdoc(({
2424
objectFieldSeparator = 'comma',
2525
objectFieldSeparatorOptionalLinebreak = true,
2626
objectFieldSeparatorTrailingPunctuation = false,
27-
propertyQuotes = null,
27+
// propertyQuotes = null,
2828
separatorForSingleObjectField = false,
2929
stringQuotes = 'single',
3030
typeBracketSpacing = '',
@@ -277,19 +277,20 @@ export default iterateJsdoc(({
277277
break;
278278
}
279279

280-
case 'JsdocTypeProperty': {
281-
const typeNode = /** @type {import('jsdoc-type-pratt-parser').PropertyResult} */ (nde);
280+
// Only suitable for namepaths (and would need changes); see https://github.com/gajus/eslint-plugin-jsdoc/issues/1524
281+
// case 'JsdocTypeProperty': {
282+
// const typeNode = /** @type {import('jsdoc-type-pratt-parser').PropertyResult} */ (nde);
282283

283-
if ((propertyQuotes ||
284-
(typeof typeNode.value === 'string' && !(/\s/v).test(typeNode.value))) &&
285-
typeNode.meta.quote !== (propertyQuotes ?? undefined)
286-
) {
287-
typeNode.meta.quote = propertyQuotes ?? undefined;
288-
errorMessage = `Inconsistent ${propertyQuotes} property quotes usage`;
289-
}
284+
// if ((propertyQuotes ||
285+
// (typeof typeNode.value === 'string' && !(/\s/v).test(typeNode.value))) &&
286+
// typeNode.meta.quote !== (propertyQuotes ?? undefined)
287+
// ) {
288+
// typeNode.meta.quote = propertyQuotes ?? undefined;
289+
// errorMessage = `Inconsistent ${propertyQuotes} property quotes usage`;
290+
// }
290291

291-
break;
292-
}
292+
// break;
293+
// }
293294

294295
case 'JsdocTypeStringValue': {
295296
const typeNode = /** @type {import('jsdoc-type-pratt-parser').StringValueResult} */ (nde);
@@ -405,13 +406,13 @@ export default iterateJsdoc(({
405406
objectFieldSeparatorTrailingPunctuation: {
406407
type: 'boolean',
407408
},
408-
propertyQuotes: {
409-
enum: [
410-
'double',
411-
'single',
412-
null,
413-
],
414-
},
409+
// propertyQuotes: {
410+
// enum: [
411+
// 'double',
412+
// 'single',
413+
// null,
414+
// ],
415+
// },
415416
separatorForSingleObjectField: {
416417
type: 'boolean',
417418
},

test/rules/assertions/typeFormatting.js

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -287,33 +287,33 @@ export default {
287287
*/
288288
`,
289289
},
290-
{
291-
code: `
292-
/**
293-
* @param {ab.cd.ef} cfg
294-
*/
295-
`,
296-
errors: [
297-
{
298-
line: 3,
299-
message: 'Inconsistent double property quotes usage',
300-
},
301-
{
302-
line: 3,
303-
message: 'Inconsistent double property quotes usage',
304-
},
305-
],
306-
options: [
307-
{
308-
propertyQuotes: 'double',
309-
},
310-
],
311-
output: `
312-
/**
313-
* @param {ab."cd"."ef"} cfg
314-
*/
315-
`,
316-
},
290+
// {
291+
// code: `
292+
// /**
293+
// * @param {ab.cd.ef} cfg
294+
// */
295+
// `,
296+
// errors: [
297+
// {
298+
// line: 3,
299+
// message: 'Inconsistent double property quotes usage',
300+
// },
301+
// {
302+
// line: 3,
303+
// message: 'Inconsistent double property quotes usage',
304+
// },
305+
// ],
306+
// options: [
307+
// {
308+
// propertyQuotes: 'double',
309+
// },
310+
// ],
311+
// output: `
312+
// /**
313+
// * @param {ab."cd"."ef"} cfg
314+
// */
315+
// `,
316+
// },
317317
{
318318
code: `
319319
/**
@@ -627,29 +627,29 @@ export default {
627627
*/
628628
`,
629629
},
630-
{
631-
code: `
632-
/**
633-
* @param {ab."cd".ef} cfg
634-
*/
635-
`,
636-
errors: [
637-
{
638-
line: 3,
639-
message: 'Inconsistent null property quotes usage',
640-
},
641-
],
642-
options: [
643-
{
644-
propertyQuotes: null,
645-
},
646-
],
647-
output: `
648-
/**
649-
* @param {ab.cd.ef} cfg
650-
*/
651-
`,
652-
},
630+
// {
631+
// code: `
632+
// /**
633+
// * @param {ab."cd".ef} cfg
634+
// */
635+
// `,
636+
// errors: [
637+
// {
638+
// line: 3,
639+
// message: 'Inconsistent null property quotes usage',
640+
// },
641+
// ],
642+
// options: [
643+
// {
644+
// propertyQuotes: null,
645+
// },
646+
// ],
647+
// output: `
648+
// /**
649+
// * @param {ab.cd.ef} cfg
650+
// */
651+
// `,
652+
// },
653653
{
654654
code: `
655655
/**
@@ -801,30 +801,30 @@ export default {
801801
},
802802
],
803803
},
804-
{
805-
code: `
806-
/**
807-
* @param {ab.cd.ef} cfg
808-
*/
809-
`,
810-
options: [
811-
{
812-
propertyQuotes: null,
813-
},
814-
],
815-
},
816-
{
817-
code: `
818-
/**
819-
* @param {ab."cd ef".gh} cfg
820-
*/
821-
`,
822-
options: [
823-
{
824-
propertyQuotes: null,
825-
},
826-
],
827-
},
804+
// {
805+
// code: `
806+
// /**
807+
// * @param {ab.cd.ef} cfg
808+
// */
809+
// `,
810+
// options: [
811+
// {
812+
// propertyQuotes: null,
813+
// },
814+
// ],
815+
// },
816+
// {
817+
// code: `
818+
// /**
819+
// * @param {ab."cd ef".gh} cfg
820+
// */
821+
// `,
822+
// options: [
823+
// {
824+
// propertyQuotes: null,
825+
// },
826+
// ],
827+
// },
828828
{
829829
code: `
830830
/**

0 commit comments

Comments
 (0)