HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/stylelint-no-px/test/index.js
'use strict'

const testRule = require('stylelint-test-rule-tape')
const useRem = require('..')

const defaultTest = {
  ruleName: useRem.ruleName,

  config: [true, {ignore: ['1px']}],

  skipBasicChecks: true,

  accept: [
    { code: '.foo { border-left: 1px solid #333; }' },
    { code: '.foo { border-left: 0px solid #333; }' },
    { code: '.foo { width: 1px; }' },
  ],

  reject: [
    {
      code: '.foo { font-size: 15px; }',
      line: 1,
      column: 8,
    },
    {
      code: '.foo { margin-left: -10px; }',
      line: 1,
      column: 8,
    },
    {
      code: '.foo { margin-left: +10px; }',
      line: 1,
      column: 8,
    },
    {
      code: '@width: 1;\n.foo { border-width: ~\'@{width}px solid #333\'; }',
      line: 2,
      column: 8,
    },
    {
      code: '@width: 10px;\n.foo { border-width: @width * 2 solid #333; }',
      line: 1,
      column: 1,
    },
  ],
}

// border && 1px
testRule(useRem.rule, defaultTest)

// border && 1px
testRule(useRem.rule, Object.assign({}, defaultTest, {
  config: true,
}))

// all
testRule(useRem.rule, {
  ruleName: useRem.ruleName,

  config: [true, {ignore: []}],

  skipBasicChecks: true,

  accept: [
  ],

  reject: [
    {
      code: '.foo { border-left: 1px solid #333; }',
      line: 1,
      column: 8,
    },
    {
      code: '@width: 1;\n.foo { border-width: ~\'@{width}px solid #333\'; }',
      line: 2,
      column: 8,
    },
    {
      code: '@width: 10px;\n.foo { border-width: @width * 2 solid #333; }',
      line: 1,
      column: 1,
    },
  ],
})

// font || 1px
testRule(useRem.rule, {
  ruleName: useRem.ruleName,

  config: [true, {ignore: ['1px', 'font']}],

  skipBasicChecks: true,

  accept: [
    { code: '.foo { border-left: 1px solid #333; }' },
    { code: '.foo { font-size: 15px; }' },
    { code: '.foo { font-size: 1px; }' },
  ],

  reject: [
    {
      code: '@width: 1;\n.foo { border-width: ~\'@{width}px solid #333\'; }',
      line: 2,
      column: 8,
    },
    {
      code: '@width: 10px;\n.foo { border-width: @width * 2 solid #333; }',
      line: 1,
      column: 1,
    },
  ],
})

// font
testRule(useRem.rule, {
  ruleName: useRem.ruleName,

  config: [true, {ignore: ['font']}],

  skipBasicChecks: true,

  accept: [
    { code: '.foo { font-size: 15px; }' },
    { code: '.foo { font-size: 1px; }' },
  ],

  reject: [
    {
      code: '.foo { border-left: 1px solid #333; }',
      line: 1,
      column: 8,
    },
    {
      code: '@width: 1;\n.foo { border-width: ~\'@{width}px solid #333\'; }',
      line: 2,
      column: 8,
    },
    {
      code: '@width: 10px;\n.foo { border-width: @width * 2 solid #333; }',
      line: 1,
      column: 1,
    },
  ],
})

// disabled
testRule(useRem.rule, {
  ruleName: useRem.ruleName,

  config: false,

  skipBasicChecks: true,

  accept: [
    {
      code: '.foo { padding: 20px; }',
      line: 2,
      column: 8,
    },
    {
      code: '@width: 10px;\n.foo { border-width: @width * 2 solid #333; }',
      line: 1,
      column: 1,
    },
  ],
})

// ignoreFunctions
testRule(useRem.rule, {
  ruleName: useRem.ruleName,

  config: [true, {ignoreFunctions: ['rem', 'rem-calc']}],

  skipBasicChecks: true,

  accept: [
    { code: '.foo { font-size: rem(15px); border-left: rem-calc(12px) solid #333; }' },
  ],

  reject: [
    {
      code: '.foo { width: calc(100% - 12px); }',
      line: 1,
      column: 8,
    },
  ],
})