Enable @stylistic/spaced-comment rule (#17941)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-09-23 17:24:03 +08:00
1 parent 27b9d59271
commit c9df58f5f9
19 files changed
+48 -32

No files matched your search

+1
View File
@@ -150,6 +150,7 @@ export default [
avoidEscape: true,
},
],
"@stylistic/spaced-comment": "error",
/* @typescript-eslint/eslint-plugin */
"@typescript-eslint/prefer-ts-expect-error": "error",
+1 -1
View File
@@ -32,7 +32,7 @@ function createParseError(error) {
return error;
}
function parse(text /*, options */) {
function parse(text /* , options */) {
let ast;
try {
ast = parseGraphql(text, parseOptions);
+1 -1
View File
@@ -1,6 +1,6 @@
import { dedent, hardline, softline } from "../document/builders.js";
function embed(path /*, options*/) {
function embed(path /* , options*/) {
const { node } = path;
if (node.type !== "TextNode") {
+1 -1
View File
@@ -57,7 +57,7 @@ const glimmerParseOptions = {
plugins: { ast: [glimmerPrettierParsePlugin] },
};
function parse(text /*, options */) {
function parse(text /* , options */) {
let ast;
try {
ast = parseGlimmer(text, glimmerParseOptions);
+1 -1
View File
@@ -72,7 +72,7 @@ function parseIeConditionalStartComment(node, parseHtml, match) {
};
}
function parseIeConditionalEndComment(node /*, parseHtml, match */) {
function parseIeConditionalEndComment(node /* , parseHtml, match */) {
return {
type: "ieConditionalEndComment",
sourceSpan: node.sourceSpan,
+1 -1
View File
@@ -14,7 +14,7 @@ import {
} from "./utils.js";
function createAngularPrinter({ parser }) {
return (textToDoc, print, path /*, options*/) =>
return (textToDoc, print, path /* , options*/) =>
formatAttributeValue(
getUnescapedAttributeValue(path.node),
textToDoc,
+1 -1
View File
@@ -5,7 +5,7 @@ import { printExpand } from "./utils.js";
/** @import {Doc} from "../../document/builders.js" */
function printSrcset(path /*, options*/) {
function printSrcset(path /* , options*/) {
if (
path.node.fullName === "srcset" &&
(path.parent.fullName === "img" || path.parent.fullName === "source")
+5 -5
View File
@@ -32,7 +32,7 @@ function preprocess(ast, options) {
return ast;
}
function removeIgnorableFirstLf(ast /*, options */) {
function removeIgnorableFirstLf(ast /* , options */) {
ast.walk((node) => {
if (
node.type === "element" &&
@@ -52,7 +52,7 @@ function removeIgnorableFirstLf(ast /*, options */) {
}
function mergeIfConditionalStartEndCommentIntoElementOpeningTag(
ast /*, options */,
ast /* , options */,
) {
/**
* <!--[if ...]><!--><target><!--<![endif]-->
@@ -129,7 +129,7 @@ function mergeNodeIntoText(ast, shouldMerge, getValue) {
});
}
function mergeCdataIntoText(ast /*, options */) {
function mergeCdataIntoText(ast /* , options */) {
return mergeNodeIntoText(
ast,
(node) => node.type === "cdata",
@@ -137,7 +137,7 @@ function mergeCdataIntoText(ast /*, options */) {
);
}
function mergeSimpleElementIntoText(ast /*, options */) {
function mergeSimpleElementIntoText(ast /* , options */) {
const isSimpleElement = (node) =>
node.type === "element" &&
node.attrs.length === 0 &&
@@ -327,7 +327,7 @@ function extractWhitespaces(ast, options) {
});
}
function addIsSelfClosing(ast /*, options */) {
function addIsSelfClosing(ast /* , options */) {
ast.walk((node) => {
node.isSelfClosing =
!node.children ||
+2 -2
View File
@@ -4,7 +4,7 @@ import isNonEmptyArray from "../../utils/is-non-empty-array.js";
import { printTemplateExpressions } from "../print/template-literal.js";
import { isAngularComponentStyles } from "./utils.js";
async function printEmbedCss(textToDoc, print, path /*, options*/) {
async function printEmbedCss(textToDoc, print, path /* , options*/) {
const { node } = path;
// Get full template literal with expressions replaced by placeholders
@@ -157,7 +157,7 @@ function isCssProp({ parent, grandparent }) {
);
}
function printCss(path /*, options*/) {
function printCss(path /* , options*/) {
if (
isStyledJsx(path) ||
isStyledComponents(path) ||
+2 -2
View File
@@ -5,7 +5,7 @@ import {
} from "../print/template-literal.js";
import { hasLanguageComment } from "./utils.js";
async function printEmbedGraphQL(textToDoc, print, path /*, options*/) {
async function printEmbedGraphQL(textToDoc, print, path /* , options*/) {
const { node } = path;
const numQuasis = node.quasis.length;
@@ -121,7 +121,7 @@ function isGraphQL({ node, parent }) {
);
}
function printGraphql(path /*, options*/) {
function printGraphql(path /* , options*/) {
if (isGraphQL(path)) {
return printEmbedGraphQL;
}
+1 -1
View File
@@ -123,7 +123,7 @@ function isHtml(path) {
const printEmbedHtml = printEmbedHtmlLike.bind(undefined, "html");
const printEmbedAngular = printEmbedHtmlLike.bind(undefined, "angular");
function printHtml(path /*, options*/) {
function printHtml(path /* , options*/) {
if (isHtml(path)) {
return printEmbedHtml;
}
+2 -2
View File
@@ -6,7 +6,7 @@ import {
} from "../../document/builders.js";
import { escapeTemplateCharacters } from "../print/template-literal.js";
async function printEmbedMarkdown(textToDoc, print, path /*, options*/) {
async function printEmbedMarkdown(textToDoc, print, path /* , options*/) {
const { node } = path;
let text = node.quasis[0].value.raw.replaceAll(
/((?:\\\\)*)\\`/gu,
@@ -34,7 +34,7 @@ function getIndentation(str) {
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
}
function printMarkdown(path /*, options*/) {
function printMarkdown(path /* , options*/) {
if (isMarkdown(path)) {
return printEmbedMarkdown;
}
+1 -1
View File
@@ -37,7 +37,7 @@ const parseOptions = {
allowReturnOutsideFunction: true,
};
async function parse(text /*, options*/) {
async function parse(text /* , options*/) {
let ast;
try {
ast = await hermesParse(text, parseOptions);
+4 -4
View File
@@ -743,7 +743,7 @@ function printJsxClosingElement(path, options, print) {
return parts;
}
function printJsxOpeningClosingFragment(path, options /*, print*/) {
function printJsxOpeningClosingFragment(path, options /* , print*/) {
const { node } = path;
const nodeHasComment = hasComment(node);
const hasOwnLineComment = hasComment(node, CommentCheckFlags.Line);
@@ -772,7 +772,7 @@ function printJsxElement(path, options, print) {
return maybeWrapJsxElementInParens(path, elem, options);
}
function printJsxEmptyExpression(path, options /*, print*/) {
function printJsxEmptyExpression(path, options /* , print*/) {
const { node } = path;
const requiresHardline = hasComment(node, CommentCheckFlags.Line);
@@ -835,9 +835,9 @@ function printJsx(path, options, print) {
return printJsxClosingElement(path, options, print);
case "JSXOpeningFragment":
case "JSXClosingFragment":
return printJsxOpeningClosingFragment(path, options /*, print*/);
return printJsxOpeningClosingFragment(path, options /* , print*/);
case "JSXEmptyExpression":
return printJsxEmptyExpression(path, options /*, print*/);
return printJsxEmptyExpression(path, options /* , print*/);
case "JSXText":
/* c8 ignore next */
throw new Error("JSXText should be handled by JSXElement");
+1 -1
View File
@@ -6,7 +6,7 @@ import printString from "../../utils/print-string.js";
* @import {Node} from "../types/estree.js"
*/
function printLiteral(path, options /*, print*/) {
function printLiteral(path, options /* , print*/) {
const { node } = path;
switch (node.type) {
+1 -1
View File
@@ -80,7 +80,7 @@ const ignoredProperties = new Set([
"tokens",
]);
function clean(original, cloned /*, parent*/) {
function clean(original, cloned /* , parent*/) {
const { type } = original;
// We print quoted key
if (type === "ObjectProperty") {
+1 -1
View File
@@ -56,7 +56,7 @@ const tokenizeEsComment = (eat, value) => {
};
/* c8 ignore next 2 */
tokenizeEsSyntax.locator = (value /*, fromIndex*/) =>
tokenizeEsSyntax.locator = (value /* , fromIndex*/) =>
isExport(value) || isImport(value) ? -1 : 1;
tokenizeEsComment.locator = (value, fromIndex) => value.indexOf("{", fromIndex);
+1 -1
View File
@@ -408,7 +408,7 @@ function printFlowScalarContent(nodeType, content, options) {
);
}
function clean(original, cloned /*, parent */) {
function clean(original, cloned /* , parent */) {
if (isNode(original)) {
switch (original.type) {
case "comment":
+20 -5
View File
@@ -181,9 +181,20 @@ const config = {
to: "/docs/install",
},
{
html: /*html*/ `
<a href="https://www.netlify.com" target="_blank" rel="noreferrer noopener" aria-label="Deploys by Netlify">
<img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" alt="Deploys by Netlify" width="114" height="51" style="margin-top: 8px;" />
html: /* HTML */ `
<a
href="https://www.netlify.com"
target="_blank"
rel="noreferrer noopener"
aria-label="Deploys by Netlify"
>
<img
src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg"
alt="Deploys by Netlify"
width="114"
height="51"
style="margin-top: 8px;"
/>
</a>
`,
},
@@ -222,7 +233,7 @@ const config = {
href: `${GITHUB_URL}/issues`,
},
{
html: /*html*/ `
html: /* HTML */ `
<a
href="https://github.com/prettier/prettier"
target="_blank"
@@ -230,7 +241,11 @@ const config = {
aria-label="Star this project on GitHub"
class="footer__github-stars"
>
<img src="https://img.shields.io/github/stars/prettier/prettier?style=social" loading="lazy" alt="Star this project on GitHub" />
<img
src="https://img.shields.io/github/stars/prettier/prettier?style=social"
loading="lazy"
alt="Star this project on GitHub"
/>
</a>
`,
},