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

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