You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.6 KiB

3 months ago
  1. # stylehacks
  2. > Detect/remove browser hacks from CSS files.
  3. ## Install
  4. With [npm](https://npmjs.org/package/stylehacks) do:
  5. ```
  6. npm install stylehacks --save
  7. ```
  8. ## Example
  9. In its default mode, stylehacks will remove hacks from your CSS file, based on
  10. the browsers that you wish to support.
  11. ### Input
  12. ```css
  13. h1 {
  14. _color: white;
  15. color: rgba(255, 255, 255, 0.5);
  16. }
  17. ```
  18. ### Output
  19. ```css
  20. h1 {
  21. color: rgba(255, 255, 255, 0.5);
  22. }
  23. ```
  24. ## API
  25. ### `stylehacks.detect(node)`
  26. Type: `function`
  27. Returns: `boolean`
  28. This method will take any PostCSS *node*, run applicable plugins depending on
  29. its type, then will return a boolean depending on whether it found any of
  30. the supported hacks. For example, if the `decl` node found below is passed to
  31. the `detect` function, it will return `true`. But if the `rule` node is passed,
  32. it will return `false` instead.
  33. ```css
  34. h1 { _color: red }
  35. ```
  36. ### `postcss([ stylehacks(opts) ])`
  37. stylehacks can also be consumed as a PostCSS plugin. See the
  38. [documentation](https://github.com/postcss/postcss#usage) for examples for
  39. your environment.
  40. #### options
  41. ##### lint
  42. Type: `boolean`
  43. Default: `false`
  44. If lint mode is enabled, stylehacks will not remove hacks from the CSS; instead,
  45. it will add warnings to `Result#messages`.
  46. ## Related
  47. stylehacks works well with your existing PostCSS setup:
  48. * [stylelint] - Comprehensive & modern CSS linter, to ensure that your code
  49. style rules are respected.
  50. ## Contributing
  51. Pull requests are welcome. If you add functionality, then please add unit tests
  52. to cover it.
  53. ## License
  54. MIT © [Ben Briggs](http://beneb.info)
  55. [stylelint]: https://github.com/stylelint/stylelint