Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ignore to version 5.0.4 (#3773)
- Loading branch information
1 parent
a9a68dd
commit 0c801e7
Showing
10 changed files
with
69 additions
and
8 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Paths are resolved absolutely to this directory | ||
|
||
../fixtures/*.css | ||
!../fixtures/invalid-hex.css | ||
fixtures/*.css | ||
!fixtures/invalid-hex.css |
5 changes: 5 additions & 0 deletions
5
lib/__tests__/stylelintignore-test/fixtures/config-block-no-empty.json
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,5 @@ | ||
{ | ||
"rules": { | ||
"block-no-empty": true | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
lib/__tests__/stylelintignore-test/fixtures/config-color-no-invalid-hex.json
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,5 @@ | ||
{ | ||
"rules": { | ||
"color-no-invalid-hex": true | ||
} | ||
} |
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,9 @@ | ||
.foo { | ||
color: pink; | ||
} | ||
|
||
.bar {} | ||
|
||
.baz { | ||
background: orange; | ||
} |
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 @@ | ||
a { | ||
color: #zzzzzz; | ||
} |
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
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,20 @@ | ||
"use strict"; | ||
|
||
const filterFilePaths = require("../filterFilePaths"); | ||
const ignore = require("ignore"); | ||
|
||
describe("filterFilePaths", () => { | ||
it("empty ignorefile", () => { | ||
const ignorer = ignore().add(""); | ||
const files = ["a.css", "b/c/d.css", "e/f.css", "../w.css"]; | ||
|
||
expect(filterFilePaths(ignorer, files)).toEqual(files); | ||
}); | ||
|
||
it("ignore some files", () => { | ||
const ignorer = ignore().add("*.css\n!e/f.css"); | ||
const files = ["a.css", "b/c/d.css", "e/f.css", "../w.css"]; | ||
|
||
expect(filterFilePaths(ignorer, files)).toEqual(["e/f.css", "../w.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,16 @@ | ||
"use strict"; | ||
|
||
const { isPathValid } = require("ignore").default; | ||
|
||
module.exports = function filterFilePaths(ignorer, filePaths) { | ||
const validForIgnore = filePaths.filter(isPathValid); | ||
// Paths which starts with `..` are not valid for `ignore`, e. g. `../style.css` | ||
const notValidForIgnore = filePaths.filter(p => !validForIgnore.includes(p)); | ||
|
||
const filteredByIgnore = ignorer.filter(validForIgnore); | ||
|
||
// Preserving files order, while removing paths which were filtered by `ignore` | ||
return filePaths.filter( | ||
p => notValidForIgnore.includes(p) || filteredByIgnore.includes(p) | ||
); | ||
}; |
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