An open API service indexing awesome lists of open source software.

https://github.com/slamdunk/stylelint-no-browser-hacks

Stylelint plugin for stylehacks linting
https://github.com/slamdunk/stylelint-no-browser-hacks

no-browser-hacks stylehacks stylelint stylelint-plugin

Last synced: 10 months ago
JSON representation

Stylelint plugin for stylehacks linting

Awesome Lists containing this project

README

          

# stylelint-no-browser-hacks

[![Node.js CI](https://github.com/Slamdunk/stylelint-no-browser-hacks/actions/workflows/test.yml/badge.svg)](https://github.com/Slamdunk/stylelint-no-browser-hacks/actions/workflows/test.yml)
[![Latest version][npm-v-img]][npm]
[![Downloads][npm-d-img]][npm]

A [stylelint] plugin that disallow browser hacks that are irrelevant to the
browsers you are targeting, using [stylehacks].

Original rule: [stylelint/no-browser-hacks][original-rule].

Disallow browser hacks that are irrelevant to the browsers you are targeting.

```css
h1 { _color: white; }
/** ↑
* Hacks like this */
```

If you are uncertain what "browser hacks" are, ["An Introduction to
Browser-Specific Hacks"][sitepoint-browser-specific-css-hacks]
explains it well.

This rule uses [stylehacks] to detect the hacks. Then, in the spirit of
stylelint, it tells you that you've done something wrong. If instead you would
like to automatically remove browser hacks, use [stylehacks] directly.

[stylehacks] is only compatible with standard CSS syntax, and does not support
nested properties nor custom property sets.

Bugs and feature requests should be reported on the
[stylehacks issue tracker][stylehacks-issues].

## Installation

```
npm install stylelint-no-browser-hacks
```

## Usage

Add `stylelint-no-browser-hacks` to your stylelint config plugins array, then
add rules you need to the rules list.
Note that the rule is namespaced with `plugin/`.

Like so:

```json
// .stylelintrc
{
"plugins": [
"stylelint-no-browser-hacks"
],
"rules": {
// ...
"plugin/no-browser-hacks": [true],
// ...
}
}
```

## Options

### `true`

Defaults to the browserslist default, which targets modern browsers.

The following patterns are considered warnings:

```css
a { color/*\**/: pink\9; }
```

As this hack targets IE7-8.

[npm]: https://www.npmjs.com/package/stylelint-no-browser-hacks
[npm-v-img]: https://img.shields.io/npm/v/stylelint-no-browser-hacks.svg
[npm-d-img]: https://img.shields.io/npm/dt/stylelint-no-browser-hacks.svg
[stylelint]: https://stylelint.io/
[stylehacks]: https://github.com/ben-eb/stylehacks
[stylehacks-issues]: https://github.com/ben-eb/stylehacks/issues
[original-rule]: https://github.com/stylelint/stylelint/tree/7.9.0/lib/rules/no-browser-hacks
[sitepoint-browser-specific-css-hacks]: https://www.sitepoint.com/browser-specific-css-hacks/
[browserslist]: https://github.com/ai/browserslist