All files / plugins selector-no-utility.js

73.33% Statements 11/15
50% Branches 2/4
66.67% Functions 2/3
73.33% Lines 11/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 362x   2x   2x 1x         1x 1x             1x 1x 1x     1x             1x          
const stylelint = require('stylelint')
 
const ruleName = 'primer/selector-no-utility'
 
module.exports = stylelint.createPlugin(ruleName, (enabled, ...args) => {
  Iif (!enabled) {
    return noop
  }
 
  let selectorNoUtility
  try {
    selectorNoUtility = require('stylelint-selector-no-utility')
  } catch (error) {
    // eslint-disable-next-line no-console
    console.warn(`Unable to require('stylelint-selector-no-utility'): ${error}`)
    return noop
  }
 
  const deprecatedPlugin = selectorNoUtility.rule(enabled, ...args)
  return (root, result) => {
    Iif (enabled === false) {
      return
    }
    result.warn(
      `'${ruleName}' has been deprecated and will be removed in stylelint-config-primer@7.0.0. Please update your rules to use 'primer/no-override'.`,
      {
        stylelintType: 'deprecation',
        stylelintReference: 'https://github.com/primer/stylelint-config-primer#deprecations'
      }
    )
    return deprecatedPlugin(root, result)
  }
})
 
function noop() {}