Add ignore next warning control comment
This commit is contained in:
1 parent
b3dc3ffd6c
commit
d484431a9c
5 files changed
+130
-3
No files matched your search
+20
-2
@@ -5,7 +5,8 @@ let insertAreas = require('./hacks/grid-utils').insertAreas
|
||||
|
||||
const OLD_LINEAR = /(^|[^-])linear-gradient\(\s*(top|left|right|bottom)/i
|
||||
const OLD_RADIAL = /(^|[^-])radial-gradient\(\s*\d+(\w*|%)\s+\d+(\w*|%)\s*,/i
|
||||
const IGNORE_NEXT = /(!\s*)?autoprefixer:\s*ignore\s+next/i
|
||||
const IGNORE_NEXT = /(!\s*)?autoprefixer:\s*ignore\s+next(?!\s+warning)/i
|
||||
const IGNORE_NEXT_WARNING = /(!\s*)?autoprefixer:\s*ignore\s+next\s+warning/i
|
||||
const GRID_REGEX = /(!\s*)?autoprefixer\s*grid:\s*(on|off|(no-)?autoplace)/i
|
||||
|
||||
const SIZES = [
|
||||
@@ -55,6 +56,13 @@ class Processor {
|
||||
* Add necessary prefixes
|
||||
*/
|
||||
add(css, result) {
|
||||
// Mark nodes before prefixes are inserted between them and comments
|
||||
css.walkComments(comment => {
|
||||
if (IGNORE_NEXT_WARNING.test(comment.text) && comment.next()) {
|
||||
comment.next()._autoprefixerIgnoreWarning = true
|
||||
}
|
||||
})
|
||||
|
||||
// At-rules
|
||||
let resolution = this.prefixes.add['@resolution']
|
||||
let keyframes = this.prefixes.add['@keyframes']
|
||||
@@ -366,7 +374,7 @@ class Processor {
|
||||
}
|
||||
|
||||
// Values
|
||||
return css.walkDecls(decl => {
|
||||
css.walkDecls(decl => {
|
||||
if (this.disabledValue(decl, result)) return
|
||||
|
||||
let unprefixed = this.prefixes.unprefixed(decl.prop)
|
||||
@@ -378,6 +386,16 @@ class Processor {
|
||||
}
|
||||
Value.save(this.prefixes, decl)
|
||||
})
|
||||
|
||||
// Remove warnings hidden by ignore next warning control comments
|
||||
result.messages = result.messages.filter(i => {
|
||||
return !(
|
||||
i.type === 'warning' &&
|
||||
i.plugin === 'autoprefixer' &&
|
||||
i.node &&
|
||||
i.node._autoprefixerIgnoreWarning
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user