2 * @fileoverview Rule to flag use of certain node types
3 * @author Burak Yigit Kaya
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
16 description: "disallow specified syntax",
17 category: "Stylistic Issues",
19 url: "https://eslint.org/docs/rules/no-restricted-syntax"
32 selector: { type: "string" },
33 message: { type: "string" }
35 required: ["selector"],
36 additionalProperties: false
45 // eslint-disable-next-line eslint-plugin/report-message-format
46 restrictedSyntax: "{{message}}"
51 return context.options.reduce((result, selectorOrObject) => {
52 const isStringFormat = (typeof selectorOrObject === "string");
53 const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message);
55 const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector;
56 const message = hasCustomMessage ? selectorOrObject.message : `Using '${selector}' is not allowed.`;
58 return Object.assign(result, {
62 messageId: "restrictedSyntax",