Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit c47c182

Browse files
authored
Merge pull request #67 from emilgoldsmith/feature/#64/support-ignoring-rules-outside-TTL
Support ignoring rules outside of TTL
2 parents 2786011 + cb19500 commit c47c182

14 files changed

+341
-978
lines changed

.lintstagedrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"{src,test}/**/*.{js,jsx}": [
2+
"{src/**/*.{js,jsx},test/*.{js,jsx}}": [
33
"prettier --print-width 100 --tab-width 2 --no-semi --single-quote --write",
44
"git add",
55
"eslint"

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,33 @@ npm run lint:css
6060

6161
### Syntax notes
6262
#### Turning rules off from within your CSS
63-
In order for `stylelint-processor-styled-components` to parse your `stylelint-disable` comments (see the [stylelint documentation](https://stylelint.io/user-guide/configuration/#turning-rules-off-from-within-your-css) for all allowed syntax) they must be inside the actual Styled Components CSS as such:
63+
Turning off rules with `stylelint-disable`-like comments (see the [stylelint documentation](https://stylelint.io/user-guide/configuration/#turning-rules-off-from-within-your-css) for all allowed syntax) is fully supported inside and outside of the tagged template literals, do note though that what actually happens behind the scene is that all `stylelint-(disable|enable)` comments are moved into the compiled css that is actually linted, so something like this:
64+
6465

65-
**Wrong**:
6666
```
67-
/* stylelint-disable color-named */
67+
/* stylelint-disable */
6868
import React from 'react';
6969
import styled from 'styled-components';
7070
7171
const Wrapper = styled.div`
72+
/* stylelint-disable */
7273
background-color: red;
7374
`;
7475
```
75-
**Right**:
76+
or even
7677
```
78+
/* stylelint-disable */
7779
import React from 'react';
7880
import styled from 'styled-components';
7981
8082
const Wrapper = styled.div`
81-
/* stylelint-disable color-named */
83+
/* stylelint-disable-next-line */
8284
background-color: red;
8385
`;
8486
```
8587

88+
would throw a stylelint error similar to `All rules have already been disabled (CssSyntaxError)`.
89+
8690
#### Interpolation linting
8791
We do not currently support linting interpolations as it could be a big performance hit though we aspire to have at least partial support in the future. You can of course lint your own mixins in their separate files, but it won't be linted in context, the implementation currently just inserts relevant dummy values. This, we are afraid, means you won't be able to lint cases such as `declaration-block-no-duplicate-properties` etc. and won't be able to lint outside mixins such as [polished](https://github.com/styled-components/polished).
8892

0 commit comments

Comments
 (0)