Skip to content

Commit

Permalink
fix: Ignore proprietary DXImageTransform.Microsoft MS filters (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntwb committed May 31, 2020
1 parent 7e7624d commit d63184d
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* function-name-case */

a {
width: Calc(5% - 10em);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* function-name-case */

a {
width: calc(5% - 10em);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#1e8cbe", endColorstr="#0074a2", GradientType=0);
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
}
84 changes: 84 additions & 0 deletions packages/stylelint-config-wordpress/__tests__/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"use strict"

const fs = require("fs")
const config = require("../")
const stylelint = require("stylelint")

const validCss = fs.readFileSync("./__tests__/functions-valid.css", "utf-8")
const invalidCss = fs.readFileSync("./__tests__/functions-invalid.css", "utf-8")

describe("flags no warnings with valid functions css", () => {
let result

beforeEach(() => {
result = stylelint.lint({
code: validCss,
config,
})
})

it("did not error", () => {
return result.then(data => (
expect(data.errored).toBeFalsy()
))
})

it("flags no warnings", () => {
return result.then(data => (
expect(data.results[0].warnings.length).toBe(0)
))
})
})

describe("flags warnings with invalid functions css", () => {
let result

beforeEach(() => {
result = stylelint.lint({
code: invalidCss,
config,
})
})

it("did error", () => {
return result.then(data => (
expect(data.errored).toBeTruthy()
))
})

it("flags three warnings", () => {
return result.then(data => (
expect(data.results[0].warnings.length).toBe(1)
))
})

it("correct first warning text", () => {
return result.then(data => (
expect(data.results[0].warnings[0].text).toBe("Expected \"Calc\" to be \"calc\" (function-name-case)")
))
})

it("correct first warning rule flagged", () => {
return result.then(data => (
expect(data.results[0].warnings[0].rule).toBe("function-name-case")
))
})

it("correct first warning severity flagged", () => {
return result.then(data => (
expect(data.results[0].warnings[0].severity).toBe("error")
))
})

it("correct first warning line number", () => {
return result.then(data => (
expect(data.results[0].warnings[0].line).toBe(4)
))
})

it("correct first warning column number", () => {
return result.then(data => (
expect(data.results[0].warnings[0].column).toBe(9)
))
})
})
4 changes: 3 additions & 1 deletion packages/stylelint-config-wordpress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ module.exports = {
"function-comma-space-before": "never",
"function-linear-gradient-no-nonstandard-direction": true,
"function-max-empty-lines": 1,
"function-name-case": "lower",
"function-name-case": [ "lower", {
ignoreFunctions: ["/^DXImageTransform.Microsoft.*$/"],
} ],
"function-parentheses-space-inside": "never",
"function-url-quotes": "never",
"function-whitespace-after": "always",
Expand Down

0 comments on commit d63184d

Please sign in to comment.