From d8b8be678f7f36a4ce9712fd6c322aed1b166ff5 Mon Sep 17 00:00:00 2001 From: Simon Boudrias Date: Fri, 28 Feb 2020 14:01:50 +0800 Subject: [PATCH] Fix stylelint rules conflicting with the styled-components processor --- index.js | 6 +++++- index.test.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index eba6ee8..6f72b11 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,10 @@ module.exports = { "value-no-vendor-prefix": true, "property-no-vendor-prefix": true, "no-empty-source": null, - "no-missing-end-of-source-newline": null + "no-missing-end-of-source-newline": null, + // These selectors are used as placeholders by + // styled-components preprocessor + "selector-type-no-unknown": [true, { ignoreTypes: ["$dummyValue", "/^-styled-/"] }], + "selector-type-case": ["lower", { ignoreTypes: ["$dummyValue"] }] } } diff --git a/index.test.js b/index.test.js index 7d112c3..04ca472 100644 --- a/index.test.js +++ b/index.test.js @@ -74,4 +74,23 @@ describe('stylelint-config-styled-components', () => { expect(result.errored).toBe(false) }) }) + + it('allows unknown placeholder from styled-components processor', () => { + const css = '-styled-mixin0 { color: blue; }\n$dummyValue { color: blue; }'; + expect.assertions(1) + + return stylelint + .lint({ + code: css, + config: { + extends: [ + 'stylelint-config-standard', + './index' + ] + } + }) + .then(result => { + expect(result.errored).toBe(false) + }) + }) })