Warning

Warning

Represents a plugin’s warning. It can be created using Node#warn.

Constructor

new Warning(text, optsopt)

Source:
Example
if ( decl.important ) {
    decl.warn(result, 'Avoid !important', { word: '!important' });
}
Parameters:
Name Type Attributes Description
text string

warning message

opts Object <optional>

warning options

Properties
Name Type Description
node Node

CSS node that caused the warning

word string

word in CSS source that caused the warning

index number

index in CSS node string that caused the warning

plugin string

name of the plugin that created this warning. Result#warn fills this property automatically.

Members

column :number

Source:

Column in the input file with this warning’s source.

Type:
  • number
Example
warning.column //=> 6

line :number

Source:

Line in the input file with this warning’s source

Type:
  • number
Example
warning.line //=> 5

node :Node

Source:

Contains the CSS node that caused the warning.

Type:
Example
warning.node.toString() //=> 'color: white !important'

plugin :string

Source:

The name of the plugin that created it will fill this property automatically. this warning. When you call Node#warn

Type:
  • string
Example
warning.plugin //=> 'postcss-important'

text :string

Source:

The warning message.

Type:
  • string
Example
warning.text //=> 'Try to avoid !important'

type :string

Source:

Type to filter warnings from Result#messages. Always equal to "warning".

Type:
  • string
Example
const nonWarning = result.messages.filter(i => i.type !== 'warning')

Methods

toString() → {string}

Source:

Returns a warning position and message.

Example
warning.toString() //=> 'postcss-lint:a.css:10:14: Avoid !important'
Returns:

warning position and message

Type
string