forked from coala/coala-bears
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This bear uses PostCSS plugin autoprefixer to add vendor prefixes to CSS rules. Fixes coala#280
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from coalib.bearlib.abstractions.Lint import Lint | ||
from coalib.bears.LocalBear import LocalBear | ||
|
||
|
||
class CSSAutoPrefixBear(Lint, LocalBear): | ||
executable = "postcss" | ||
arguments = "--use autoprefixer {filename}" | ||
prerequisite_command = ['postcss', '--use', 'autoprefixer'] | ||
prerequisite_fail_msg = "Autoprefixer is not installed." | ||
diff_message = "Add vendor prefixes to CSS rules." | ||
gives_corrected = True | ||
|
||
def run(self, filename, file): | ||
''' | ||
This bear adds vendor prefixes to CSS rules using ``autoprefixer`` | ||
utility. | ||
''' | ||
return self.lint(filename, file) |
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
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,22 @@ | ||
from bears.css.CSSAutoPrefixBear import CSSAutoPrefixBear | ||
from tests.LocalBearTestHelper import verify_local_bear | ||
|
||
|
||
good_file = """ | ||
.example { | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
} | ||
""".splitlines(keepends=True) | ||
|
||
bad_file = """ | ||
.example { | ||
display: flex; | ||
} | ||
""".splitlines(keepends=True) | ||
|
||
CSSAutoPrefixBear = verify_local_bear(CSSAutoPrefixBear, | ||
valid_files=(good_file,), | ||
invalid_files=(bad_file,)) |