-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to omit locals with empty declaration blocks
fixes css-modules/css-modules#127, fixes css-modules/css-modules#269
- Loading branch information
Showing
7 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...-cases/error-composes-not-defined-class-option-exportEmptyLocals-false/expected.error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
referenced class name "otherClassName" in composes not found |
3 changes: 3 additions & 0 deletions
3
test/test-cases/error-composes-not-defined-class-option-exportEmptyLocals-false/options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
exportEmptyLocals: false, | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/test-cases/error-composes-not-defined-class-option-exportEmptyLocals-false/source.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:local(.className) { | ||
composes: otherClassName; | ||
} |
34 changes: 34 additions & 0 deletions
34
test/test-cases/options-exportEmptyLocals-false/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* leaf node with contents */ | ||
._input__layer1A { | ||
color: red; | ||
} | ||
|
||
._input__layer2A /* doesn't add anything new */ { | ||
} | ||
|
||
._input__layer1B { | ||
/* totally empty, except for this comment */ | ||
} | ||
|
||
._input__layer2B { | ||
background: blue; | ||
} | ||
|
||
._input__layer3 { | ||
} | ||
|
||
._input__foo > ._input__bar { | ||
} | ||
|
||
._input__baz > ._input__qux { | ||
font-style: italic; | ||
} | ||
|
||
:export { | ||
layer1A: _input__layer1A; | ||
layer2A: _input__layer1A; | ||
layer2B: _input__layer2B; | ||
layer3: _input__layer1A _input__layer2B; | ||
baz: _input__baz; | ||
qux: _input__qux; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
exportEmptyLocals: false, | ||
}; |
29 changes: 29 additions & 0 deletions
29
test/test-cases/options-exportEmptyLocals-false/source.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* leaf node with contents */ | ||
:local(.layer1A) { | ||
color: red; | ||
} | ||
|
||
:local(.layer2A) /* doesn't add anything new */ { | ||
composes: layer1A; | ||
} | ||
|
||
:local(.layer1B) { | ||
/* totally empty, except for this comment */ | ||
} | ||
|
||
:local(.layer2B) { | ||
background: blue; | ||
composes: layer1B; | ||
} | ||
|
||
:local(.layer3) { | ||
composes: layer2A; | ||
composes: layer2B; | ||
} | ||
|
||
:local(.foo) /* empty */ > :local(.bar) { | ||
} | ||
|
||
:local(.baz) /* non-empty */ > :local(.qux) { | ||
font-style: italic; | ||
} |