-
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.
- Loading branch information
1 parent
69a5e2c
commit 91bf853
Showing
11 changed files
with
4,397 additions
and
4,456 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
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,3 @@ | ||
# Header | ||
|
||
Text |
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
const config = require(".."); | ||
const remark = require("remark"); | ||
const globby = require("globby"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const vfile = require("vfile"); | ||
|
||
function isObject(obj) { | ||
return typeof obj === "object" && obj !== null; | ||
} | ||
|
||
describe("remark-preset-lint-itgalaxy", () => { | ||
it("should have property `plugin`", () => { | ||
expect(isObject(config.plugins)).toBe(true); | ||
}); | ||
|
||
it("should have rules in property `lint` in `plugin` property", () => { | ||
expect(Object.keys(config.plugins)).not.toHaveLength(0); | ||
}); | ||
|
||
it("should have property `settings`", () => { | ||
expect(isObject(config.settings)).toBe(true); | ||
}); | ||
|
||
it("should have no error on valid syntax", () => | ||
globby(["fixtures/**/*.md"], { | ||
absolute: true, | ||
cwd: path.dirname(__filename) | ||
}).then(filePaths => | ||
Promise.all( | ||
filePaths.map(filePath => | ||
new Promise((resolve, reject) => | ||
fs.readFile(filePath, (error, contents) => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
return resolve(contents); | ||
}) | ||
).then(contents => | ||
new Promise((resolve, reject) => { | ||
// Remove `remark-validate-links`, because it doesn't work not on CLI | ||
config.plugins.splice(3, 1); | ||
|
||
const file = vfile({ | ||
path: filePath, | ||
contents: contents.toString() | ||
}); | ||
|
||
return remark() | ||
.use(config.plugins) | ||
.process(file, (error, lintedFile) => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
return resolve(lintedFile); | ||
}); | ||
}).then(file => { | ||
expect(file.messages).toHaveLength(0); | ||
|
||
return 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,7 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
hooks: { | ||
"pre-commit": "lint-staged" | ||
} | ||
}; |
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
Oops, something went wrong.