PageSourceSearch

https://stylelint.io/assets/js/9b265cb3.07f1a6aa.js

js stylelint.io collected 2026-10-02 02:26:58 UTC 22,475 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkstylelint_io=self.webpackChunkstylelint_io||[]).push([["8824"],{3341:function(e,n,s){s.r(n),s.d(n,{metadata:function(){return t},default:function(){return d},frontMatter:function(){return l},contentTitle:function(){return o},toc:function(){return c},assets:function(){return a}});var t=JSON.parse('{"id":"developer-guide/plugins","title":"Writing plugins","description":"Plugins are custom rules and sets of custom rules. They might support a particular methodology or toolset, apply to non-standard constructs and features, or be for specific use cases.","source":"@site/docs/developer-guide/plugins.md","sourceDirName":"developer-guide","slug":"/developer-guide/plugins","permalink":"/developer-guide/plugins","draft":false,"unlisted":false,"editUrl":"https://github.com/stylelint/stylelint/edit/main/docs/developer-guide/plugins.md","tags":[],"version":"current","frontMatter":{"title":"Writing plugins","sidebar_label":"Writing plugins"},"sidebar":"docs","previous":{"title":"Errors & warnings","permalink":"/user-guide/errors"},"next":{"title":"Writing custom syntaxes","permalink":"/developer-guide/syntaxes"}}'),i=s(4848),r=s(8453);let l={title:"Writing plugins",sidebar_label:"Writing plugins"},o="Writing plugins",a={},c=[{value:"The anatomy of a plugin",id:"the-anatomy-of-a-plugin",level:2},{value:"Asynchronous rules",id:"asynchronous-rules",level:3},{value:"Testing",id:"testing",level:2},{value:"<code>stylelint.utils</code>",id:"stylelintutils",level:2},{value:"<code>stylelint.utils.report()</code>",id:"stylelintutilsreport",level:3},{value:"<code>stylelint.utils.ruleMessages()</code>",id:"stylelintutilsrulemessages",level:3},{value:"<code>stylelint.utils.validateOptions()</code>",id:"stylelintutilsvalidateoptions",level:3},{value:"<code>stylelint.utils.checkAgainstRule()</code>",id:"stylelintutilscheckagainstrule",level:3},{value:"<code>stylelint.rules</code>",id:"stylelintrules",level:2},{value:"Allow primary option arrays",id:"allow-primary-option-arrays",level:2},{value:"Peer dependencies",id:"peer-dependencies",level:2},{value:"Plugin packs",id:"plugin-packs",level:2},{value:"Sharing plugins and plugin packs",id:"sharing-plugins-and-plugin-packs",level:2},{value:"Sharing configurations",id:"sharing-configurations",level:2},{value:"Quiet deprecation warnings",id:"quiet-deprecation-warnings",level:2}];function u(e){let n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"writing-plugins",children:"Writing plugins"})}),"\n",(0,i.jsx)(n.p,{children:"Plugins are custom rules and sets of custom rules. They might support a particular methodology or toolset, apply to non-standard constructs and features, or be for specific use cases."}),"\n",(0,i.jsxs)(n.p,{children:["We recommend your custom rules adhere to ",(0,i.jsx)(n.a,{href:"/contributor-guide/rules",children:"our built-in rule conventions"})," for:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"names"}),"\n",(0,i.jsx)(n.li,{children:"options"}),"\n",(0,i.jsx)(n.li,{children:"messages"}),"\n",(0,i.jsx)(n.li,{children:"tests"}),"\n",(0,i.jsx)(n.li,{children:"docs"}),"\n",(0,i.jsx)(n.li,{children:"metadata"}),"\n",(0,i.jsx)(n.li,{children:"construct-specific parsers"}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"the-anatomy-of-a-plugin",children:"The anatomy of a plugin"}),"\n",(0,i.jsx)(n.p,{children:'This example plugin disallows the word "foo" in selectors:'}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'import stylelint from "stylelint";\n\nconst {\n  createPlugin,\n  utils: { report, ruleMessages, validateOptions }\n} = stylelint;\n\nconst ruleName = "foo-org/selector-no-foo";\n\nconst messages = ruleMessages(ruleName, {\n  rejected: (selector) => `Disallowed "foo" within selector "${selector}"`\n});\n\nconst meta = {\n  url: "https://github.com/foo-org/stylelint-selector-no-foo/blob/main/README.md"\n};\n\n/** @type {import(\'stylelint\').Rule} */\nconst ruleFunction = (primary, secondaryOptions, context) => {\n  return (root, result) => {\n    const validOptions = validateOptions(result, ruleName, {\n      actual: primary,\n      possible: [true]\n    });\n\n    if (!validOptions) return;\n\n    root.walkRules((ruleNode) => {\n      const { selector } = ruleNode;\n\n      if (!selector.includes("foo")) return;\n\n      report({\n        result,\n        ruleName,\n        message: messages.rejected(selector),\n        node: ruleNode,\n        word: selector\n      });\n    });\n  };\n};\n\nruleFunction.ruleName = ruleName;\nruleFunction.messages = messages;\nruleFunction.meta = meta;\n\nexport default createPlugin(ruleName, ruleFunction);\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsxs)(n.a,{href:"https://www.t
1ypescriptlang.org/docs/handbook/jsdoc-supported-types.html#type",children:[(0,i.jsx)(n.code,{children:"@type"})," JSDoc annotation"]})," enables Typescript to autocomplete and type-check."]})}),"\n",(0,i.jsx)(n.p,{children:"The usage would be:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "plugins": ["@foo-org/stylelint-selector-no-foo"],\n  "rules": {\n    "foo-org/selector-no-foo": true\n  }\n}\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh-session",children:'$ echo \'.foo {}\' | stylelint --stdin-filename=test.css\n\ntest.css\n 1:1  \u2716  Disallowed "foo" within selector ".foo"  foo-org/selector-no-foo\n\n1 problem (1 error, 0 warnings)\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Your plugin's rule name must be namespaced, e.g. ",(0,i.jsx)(n.code,{children:"your-namespace/your-rule-name"}),", to ensure it never clashes with the built-in rules. If your plugin provides only a single rule or you can't think of a good namespace, you can use ",(0,i.jsx)(n.code,{children:"plugin/my-rule"}),". ",(0,i.jsx)(n.em,{children:"You should document your plugin's rule name (and namespace) because users need to use them in their config."})]}),"\n",(0,i.jsxs)(n.p,{children:["Use ",(0,i.jsx)(n.code,{children:"stylelint.createPlugin(ruleName, ruleFunction)"})," to ensure that your plugin is set up properly alongside other rules."]}),"\n",(0,i.jsxs)(n.p,{children:["For your plugin rule to work with the ",(0,i.jsx)(n.a,{href:"/user-guide/configure#rules",children:"standard configuration format"}),", ",(0,i.jsx)(n.code,{children:"ruleFunction"})," should accept 2 arguments:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"the primary option"}),"\n",(0,i.jsx)(n.li,{children:"optionally, a secondary options object"}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["If your plugin rule supports ",(0,i.jsx)(n.a,{href:"/contributor-guide/rules#add-autofix",children:"autofixing"}),", then ",(0,i.jsx)(n.code,{children:"meta.fixable"})," should be set to ",(0,i.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"ruleFunction"})," should return a function that is essentially a little ",(0,i.jsx)(n.a,{href:"https://postcss.org/docs/writing-a-postcss-plugin",children:"PostCSS plugin"}),". It takes 2 arguments:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"the PostCSS Root (the parsed AST)"}),"\n",(0,i.jsx)(n.li,{children:"the PostCSS LazyResult"}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["You'll have to ",(0,i.jsx)(n.a,{href:"https://postcss.org/api/",children:"learn about the PostCSS API"}),"."]}),"\n",(0,i.jsx)(n.h3,{id:"asynchronous-rules",children:"Asynchronous rules"}),"\n",(0,i.jsxs)(n.p,{children:["You can write your plugin as an ",(0,i.jsx)(n.em,{children:"async function"})," to deal with ",(0,i.jsx)(n.code,{children:"Promise"}),"."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'const ruleFunction = (primary, secondaryOptions) => {\n  return async (root, result) => {\n    // validate options...\n\n    // load disallowed words asynchronously\n    const disallowedWords = await import("./disallowed-words.js");\n\n    // traverse AST nodes...\n\n    // report a warning if a problem word is detected...\n  };\n};\n'})}),"\n",(0,i.jsx)(n.h2,{id:"testing",children:"Testing"}),"\n",(0,i.jsx)(n.p,{children:"You can use either:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"https://www.npmjs.com/package/stylelint-test-rule-node",children:(0,i.jsx)(n.code,{children:"stylelint-test-rule-node"})})," (",(0,i.jsx)(n.code,{children:"node:test"})," based)"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"https://github.com/stylelint/jest-preset-stylelint",children:(0,i.jsx)(n.code,{children:"jest-preset-stylelint"})})," (Jest based)"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Both expose a ",(0,i.jsx)(n.code,{children:"testRule"})," function that you can use to efficiently test your plugin using a schema."]}),"\n",(0,i.jsx)(n.p,{children:"For example:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'import { testRule } from "stylelint-test-rule-node";\n\nimport plugin from "./index.js";\n\nconst {\n  rule: { messages, ruleName }\n} = plugin;\n\ntestRule({\n  plugins: [plugin],\n  ruleName,\n  config: true,\n  fix: true,\n\n  accept: [\n    {\n      code: ".a {}"\n    },\n    {\n      code: ".b {}"\n    }\n  ],\n\n  reject: [\n    {\n      code: ".foo {}",\n      fixed: ".safe {}",\n      message: messages.rejected(".foo"),\n      line: 1,\n      column: 1,\n      endLine: 1,\n      endColumn: 8\n    }\n  ]\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Alternatively, you'll find more testing options in ",(0,i.jsx)(n.a,{href:"/awesome-stylelint",children:"Awesome Stylelint"}),"."]}),"\n",(0,i.jsx)(n.p,{children:"If your plugin involves more than just checking syntax, you can use Stylelint directly."}),"\n",(0,i.jsx)(n.p,{children:"For example:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'import stylelint from "stylelint";\n\nconst { lint } = stylelint;\n\nconst config = {\n  plugins: ["./index.js"],\n  rules: {\n    "foo-org/selector-no-foo": true\n  }\n};\n\nit("warns", async () => {\n  const {\n    results: [{ warnings, parseErrors }]\n  } = await lint({\n    files: ["fixtures/test.css"],\n    config\n  });\n\n  expect(parseErrors).toHaveLength(0);\n  expect(warnings).toHaveLength(1);\n\n  const [{ text, line, column }] = warnings;\n\n  expect(text).toBe(\'Disallowed "foo" within selector ".foo"\');\n  expect(line).toBe(1);\n  expect(column).toBe(1);\n});\n\nit("doesn\'t warn", async () => {\n  const {\n    results: [{ warnings, parseErrors }]\n  } = await lint({\n    code: ".foo {}",\n    config\n  });\n\n  expect(parseErrors).toHaveLength(0);\n  expect(warnings).toHaveLength(0);\n});\n'})}),"\n",(0,i.jsx)(n.h2,{id:"stylelintutils",children:(0,i.jsx)(n.code,{children:"stylelint.utils"})}),"\n",(0,i.jsx)(n.p,{children:"Stylelint exposes some useful utilities."}),"\n",(0,i.jsxs)(n.p,{children:["You're also welcome to copy any of the ",(0,i.jsx)(n.a,{href:"https://github.com/stylelint/stylelint/tree/main/lib/utils",children:"internal utils"})," into your plugin. You should not ",(0,i.jsx)(n.code,{children:"import"})," them directly, as they are not part of the public API and may change or be removed without warning."]}),"\n",(0,i.jsx)(n.h3,{id:"stylelintutilsreport",children:(0,i.jsx)(n.code,{children:"stylelint.utils.report()"})}),"\n",(0,i.jsx)(n.p,{children:"Adds problems from your plugin to the list of problems that Stylelint will report to the user."}),"\n",(0,i.jsxs)(n.p,{children:["Use ",(0,i.jsx)(n.code,{children:"stylelint.utils.report()"})," to ensure your plugin respects disabled ranges and other possible future features of Stylelint."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["Do not use PostCSS's ",(0,i.jsx)(n.a,{href:"https://postcss.org/api/#node-warn",children:(0,i.jsx)(n.code,{children:"Node#warn()"})})," method directly."]})}),"\n",(0,i.jsxs)(n.p,{children:["You can specify PostCSS's ",(0,i.jsx)(n.a,{href:"https://postcss.org/api/#warningoptions",children:"warning options"})," (e.g., ",(0,i.jsx)(n.code,{children:"word"}),", ",(0,i.jsx)(n.code,{children:"index"}),", ",(0,i.jsx)(n.code,{children:"start"}),", etc.) to detail where a problem occurs."]}),"\n",(0,i.jsx)(n.h3,{id:"stylelintutilsrulemessages",children:(0,i.jsx)(n.code,{children:"stylelint.utils.ruleMessages()"})}),"\n",(0,i.jsx)(n.p,{children:"Tailors your messages to the format of standard Stylelint rules."}),"\n",(0,i.jsx)(n.h3,{id:"stylelintutilsvalidateoptions",children:(0,i.jsx)(n.code,{children:"stylelint.utils.validateOptions()"})}),"\n",(0,i.jsx)(n.p,{children:"Validates the options for your rule."}),"\n",(0,i.jsx)(n.h3,{id:"stylelintutilscheckagainstrule",children:(0,i.jsx)(n.code,{children:"stylelint.utils.checkAgainstRule()"})}),"\n",(0,i.jsxs)(n.p,{children:["Checks CSS against a standard or custom Stylelint rule ",(0,i.jsx)(n.em,{children:"within your own rule"}),". This function provides power and flexibility for plugins authors who wish to modify, constrain, or extend the functionality of existing Stylelint rules."]}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["This is an async function. Your custom rule may need to wait until a ",(0,i.jsx)(n.code,{children:"Promise"})," returned by the function is resolved."]})}),"\n",(0,i.jsx)(n.p,{children:"It accepts an options object and a callback that is invoked with warnings from the specified rule. The options are:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"ruleName"}),": the name of the rule you are invoking"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"ruleSettings"}),": settings for the rule you are invoking"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"root"}),": the root node to run this rule against"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"result?"}),": the PostCSS result for resolving and invoking custom rules"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"context?"}),": the ",(0,i.jsx)(n.a,{href:"/contributor-guide/rules#context",children:"context"})," for the rule you are invoking"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Use the warning to create a ",(0,i.jsx)(n.em,{children:"new"})," warning ",(0,i.jsx)(n.em,{children:"from your plugin rule"})," that you report with ",(0,i.jsx)(n.a,{href:"#stylelintutilsreport",children:(0,i.jsx)(n.code,{children:"stylelint.utils.report()"})}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["For example, imagine you want to create a plugin that runs ",(0,i.jsx)(n.a,{href:"/user-guide/rules/at-rule-no-unknown",children:(0,i.jsx)(n.code,{children:"at-rule-no-unknown"})})," with a built-in list of exceptions for at-rules provided by your preprocessor-of-choice:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'const {\n  utils: { checkAgainstRule, report }\n} = stylelint;\n\nconst allowableAtRules = [/* .. */];\n\nconst ruleName = "your-own/at-rule-no-unknown";\n\nconst myPluginRule = (primary, secondaryOptions, context) => {\n  return async (root, result) => {\n    const ignoreAtRules = allowableAtRules.concat(\n      secondaryOptions?.ignoreAtRules ?? []\n    );\n    const defaultedSecondaryOptions = { ...secondaryOptions, ignoreAtRules };\n\n    await checkAgainstRule(\n      {\n        ruleName: "at-rule-no-unknown",\n        ruleSettings: [primary, defaultedSecondaryOptions],\n        root,\n        result,\n        context\n      },\n      (warning) => {\n        report({\n          ruleName,\n          result,\n          message: warning.text,\n          node: warning.node,\n          start: { line: warning.line, column: warning.column },\n          end: { line: warning.endLine, column: warning.endColumn }\n        });\n      }\n    );\n  };\n};\n'})}),"\n",(0,i.jsx)(n.h2,{id:"stylelintrules",children:(0,i.jsx)(n.code,{children:"stylelint.rules"})}),"\n",(0,i.jsxs)(n.p,{children:["All of the rule functions are available at the ",(0,i.jsx)(n.code,{children:"stylelint.rules"})," object. This allows you to build on top of existing rules for your particular needs."]}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["Every value in the ",(0,i.jsx)(n.code,{children:"stylelint.rules"})," object is a ",(0,i.jsx)(n.code,{children:"Promise"})," resolving a rule function."]})}),"\n",(0,i.jsx)(n.p,{children:"A typical use-case is to build in more complex conditionals that the rule's options allow for. For example, maybe your co
1debase uses special comment directives to customize rule options for specific stylesheets. You could build a plugin that checks those directives and then runs the appropriate rules with the right options (or doesn't run them at all)."}),"\n",(0,i.jsx)(n.p,{children:"All rules share a common signature. They are a function that accepts two arguments: a primary option and a secondary options object. And that function returns a function that has the signature of a PostCSS plugin, expecting a PostCSS root and result as its arguments."}),"\n",(0,i.jsxs)(n.p,{children:["Here's an example of a plugin that runs ",(0,i.jsx)(n.code,{children:"declaration-no-important"})," only if there is a special directive ",(0,i.jsx)(n.code,{children:"@@check-declaration-no-important"})," somewhere in the stylesheet:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'createPlugin(ruleName, (primary) => {\n  const rulePromise = stylelint.rules["declaration-no-important"];\n  const ruleRunnner = rulePromise.then((rule) => rule(primary));\n\n  return async (root, result) => {\n    if (!root.toString().includes("@@check-declaration-no-important")) {\n      return;\n    }\n\n    (await ruleRunnner)(root, result);\n  };\n});\n'})}),"\n",(0,i.jsx)(n.h2,{id:"allow-primary-option-arrays",children:"Allow primary option arrays"}),"\n",(0,i.jsxs)(n.p,{children:["If your plugin can accept an array as its primary option, you must designate this by setting the property ",(0,i.jsx)(n.code,{children:"primaryOptionArray = true"})," on your rule function. For more information, check out the ",(0,i.jsx)(n.a,{href:"/contributor-guide/rules",children:'"Working on rules"'})," doc."]}),"\n",(0,i.jsx)(n.h2,{id:"peer-dependencies",children:"Peer dependencies"}),"\n",(0,i.jsxs)(n.p,{children:["You should express, within the ",(0,i.jsx)(n.code,{children:"peerDependencies"})," key (and ",(0,i.jsx)(n.strong,{children:"not"})," within the ",(0,i.jsx)(n.code,{children:"dependencies"})," key) of your plugin's ",(0,i.jsx)(n.code,{children:"package.json"}),", what version(s) of Stylelint your plugin can be used with. This is to ensure that different versions of Stylelint are not unex
1pectedly installed."]}),"\n",(0,i.jsx)(n.p,{children:"For example, to express that your plugin can be used with Stylelint versions 14 and 15:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "peerDependencies": {\n    "stylelint": "^14.0.0 || ^15.0.0"\n  }\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"plugin-packs",children:"Plugin packs"}),"\n",(0,i.jsx)(n.p,{children:"To make a single module provide multiple rules, export an array of plugin objects (rather than a single object)."}),"\n",(0,i.jsx)(n.h2,{id:"sharing-plugins-and-plugin-packs",children:"Sharing plugins and plugin packs"}),"\n",(0,i.jsxs)(n.p,{children:["Use the ",(0,i.jsx)(n.code,{children:"stylelint-plugin"})," keyword within your ",(0,i.jsx)(n.code,{children:"package.json"}),". For example:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "keywords": ["stylelint", "stylelint-plugin"]\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"sharing-configurations",children:"Sharing configurations"}),"\n",(0,i.jsx)(n.p,{children:"You may want to create a shareable configuration for your plugins to provide a default ruleset. For example:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "plugins": ["stylelint-plugin-foo"],\n  "rules": {\n    "foo/rule-1": true,\n    "foo/rule-2": true\n  }\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["When publishing such configurations, use the ",(0,i.jsx)(n.code,{children:"stylelint-config"})," keyword within your ",(0,i.jsx)(n.code,{children:"package.json"}),". For example:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "keywords": ["stylelint", "stylelint-config"]\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"quiet-deprecation-warnings",children:"Quiet deprecation warnings"}),"\n",(0,i.jsxs)(n.p,{children:["We sometimes introduce deprecation warnings that impact plugin authors. You can individually quiet these in your plugin by handling the ",(0,i.jsx)(n.code,{children:"emitWarning"})," event."]}),"\n",(0,i.jsxs)(n.p,{children:["For example, to quiet the deprecation warning for ",(0,i.jsx)(n.code,{children:"context.fix"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-diff",metastring:"js",children:'const ruleName = "plugin/foo-bar-qux";\n\n+ const original = process.emitWarning;\n+ process.emitWarning = function emitWarning(warning, type, code, ctor) {\n+   const options = arguments[1];\n+\n+  if (\n+    options &&\n+    typeof options === "object" &&\n+    options.type === "DeprecationWarning" &&\n+    options.code === "stylelint:005" &&\n+    options.detail.includes(ruleName)\n+  ) {\n+    return;\n+  }\n+\n+  original.apply(process, arguments);\n+ };\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsx)(n.p,{children:"Note that this monkey patch might have side effects."})})]})}function d(e={}){let{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},8453:function(e,n,s){s.d(n,{R:function(){return l},x:function(){return o}});var t=s(6540);let i={},r=t.createContext(i);function l(e){let n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.