Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable stylelint rules?

Tags:

stylelint

I am using stylelints and I have some rules that I want to disable :

in less I have to do calc this way top: calc(~'50% + 30px'); but "function-calc-no-invalid" prevent it

https://stylelint.io/user-guide/rules/function-calc-no-invalid

also, I want to allow my less code to apply css to component directly so

my-componet { width:100px} so I need to disable "selector-type-no-unknown"

https://stylelint.io/user-guide/rules/selector-type-no-unknown

I tried to create a .styllelintrc file and add the following

    "selector-type-no-unknown": "custom-elements",
    "function-calc-no-invalid": "false",

and manyvariation, but I keep getting

Invalid Option: Unexpected option value "false" for rule "function-calc-no-invalid" Invalid Option: Unexpected option value "custom-elements" for rule "selector-type-no-unknown"

like image 817
Bobby Avatar asked Jun 27 '20 09:06

Bobby


People also ask

How do I turn off a rule in Stylelint?

You can learn more about how rules are configured in the stylelint user guide, e.g. how to turn rules off rules using null and configure optional secondary options like ignore: ["custom-elements"] .

How do I ignore a Stylelint error?

You can also specify a path to your ignore patterns file (absolute or relative to process. cwd() ) using the --ignore-path (in the CLI) and ignorePath (in JS) options. Alternatively, you can add an ignoreFiles property within your configuration object.


Video Answer


1 Answers

Your stylelint configuration object in your .stylelintrc file should be:

{
  "rules": {
    "function-calc-no-invalid": null,
    "selector-type-no-unknown": [
      true,
      {
        "ignore": [
          "custom-elements"
        ]
      }
    ]
  }
}

You can learn more about how rules are configured in the stylelint user guide, e.g. how to turn rules off rules using null and configure optional secondary options like ignore: ["custom-elements"].

like image 110
jeddy3 Avatar answered Oct 16 '22 16:10

jeddy3