mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 13:23:32 -06:00
Initial commit
This commit is contained in:
41
node_modules/stylelint/lib/rules/no-browser-hacks/README.md
generated
vendored
Normal file
41
node_modules/stylelint/lib/rules/no-browser-hacks/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# no-browser-hacks
|
||||
|
||||
***DEPRECATED! The plugin was deprecated in favor of [`stylelint-no-browser-hacks`](https://github.com/Slamdunk/stylelint-no-browser-hacks).***
|
||||
|
||||
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"](https://www.sitepoint.com/browser-specific-css-hacks/) explains it well.
|
||||
|
||||
This rule uses [stylehacks](https://github.com/ben-eb/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](https://github.com/ben-eb/stylehacks) directly.
|
||||
|
||||
[stylehacks](https://github.com/ben-eb/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](https://github.com/ben-eb/stylehacks/issues).
|
||||
|
||||
## 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.
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `browsers: "browserslist string"`
|
||||
|
||||
A string interpreted by [browserslist](https://github.com/ai/browserslist) that designates precisely which browsers you wish to support. Something like `"> 1%, last 2 versions, ie >= 8"`. For details about the syntax (which is the same as when using Autoprefixer, by the way), please read [the browserslist documentation](https://github.com/ai/browserslist).
|
||||
|
||||
If you set `browsers: [ "last 2 versions", "ie >=7" ]` the hack above is allowed.
|
59
node_modules/stylelint/lib/rules/no-browser-hacks/index.js
generated
vendored
Normal file
59
node_modules/stylelint/lib/rules/no-browser-hacks/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict"
|
||||
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const Result = require("postcss/lib/result")
|
||||
const _ = require("lodash")
|
||||
const stylehacks = require("stylehacks")
|
||||
|
||||
const ruleName = "no-browser-hacks"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (type, hack) => `Unexpected ${type} hack "${hack}"`,
|
||||
})
|
||||
|
||||
const rule = function (on, options) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual: on }, {
|
||||
optional: true,
|
||||
actual: options,
|
||||
possible: {
|
||||
browsers: [_.isString],
|
||||
},
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
result.warn((
|
||||
`'${ruleName}' has been deprecated and in 8.0 will be removed. Use 'stylelint-no-browser-hacks' plugin instead.`
|
||||
), {
|
||||
stylelintType: "deprecation",
|
||||
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
|
||||
})
|
||||
|
||||
const stylehacksOptions = { lint: true }
|
||||
if (options && options.browsers) {
|
||||
stylehacksOptions.browsers = options.browsers
|
||||
}
|
||||
|
||||
const stylehacksResult = new Result()
|
||||
stylehacks(stylehacksOptions)(root, stylehacksResult)
|
||||
stylehacksResult.warnings().forEach(stylehacksWarning => {
|
||||
const message = messages.rejected(stylehacksWarning.identifier, stylehacksWarning.hack)
|
||||
report({
|
||||
ruleName,
|
||||
result,
|
||||
message,
|
||||
node: stylehacksWarning.node,
|
||||
line: stylehacksWarning.line,
|
||||
column: stylehacksWarning.column,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user