Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiple rules, update test structure, and require Node.js 8 (#29)
- Loading branch information
1 parent
1d0bc31
commit a5bf993
Showing
57 changed files
with
1,692 additions
and
50 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 |
---|---|---|
|
@@ -2,4 +2,3 @@ language: node_js | |
node_js: | ||
- '10' | ||
- '8' | ||
- '6' |
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,11 +1,49 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
const gitClone = require('git-clone'); | ||
const isUrl = require('is-url-superb'); | ||
const meow = require('meow'); | ||
const pify = require('pify'); | ||
const rmfr = require('rmfr'); | ||
const tempy = require('tempy'); | ||
|
||
const findReadmeFile = require('./lib/find-readme-file'); | ||
const awesomeLint = require('.'); | ||
|
||
const cli = meow(` | ||
Usage | ||
$ awesome-lint | ||
`); | ||
const main = async () => { | ||
const cli = meow(` | ||
Usage | ||
$ awesome-lint | ||
`); | ||
|
||
const options = { }; | ||
const input = cli.input[0]; | ||
let temp = null; | ||
|
||
if (input) { | ||
if (isUrl(input)) { | ||
temp = tempy.directory(); | ||
await pify(gitClone)(input, temp); | ||
|
||
const readme = findReadmeFile(temp); | ||
if (!readme) { | ||
await rmfr(temp); | ||
throw new Error(`unable to find valid readme for "${input}"`); | ||
} | ||
|
||
options.filename = readme; | ||
} else { | ||
options.filename = input; | ||
} | ||
} else { | ||
options.filename = 'readme.md'; | ||
} | ||
|
||
await awesomeLint.report(options); | ||
|
||
if (temp) { | ||
await rmfr(temp); | ||
} | ||
}; | ||
|
||
awesomeLint.report({filename: cli.input[0] || 'readme.md'}); | ||
main(); |
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,14 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = dir => { | ||
const readmeFile = fs.readdirSync(dir).find(filename => ( | ||
/readme|readme\.md|readme\.markdown|readme.txt/i.test(filename) | ||
)); | ||
|
||
if (readmeFile) { | ||
return path.join(fs.realpathSync(dir), readmeFile); | ||
} | ||
}; |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = new Set([ | ||
'npm' | ||
]); |
File renamed without changes
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,23 @@ | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const globby = require('globby'); | ||
const rule = require('unified-lint-rule'); | ||
|
||
module.exports = rule('remark-lint:awesome/contributing', (ast, file) => { | ||
const {dirname} = file; | ||
|
||
const contributingFile = globby.sync('contributing.md', {case: false, cwd: dirname})[0]; | ||
|
||
if (!contributingFile) { | ||
file.message('Missing file contributing.md'); | ||
return; | ||
} | ||
|
||
const contributingPath = path.resolve(dirname, contributingFile); | ||
const contributing = fs.readFileSync(contributingPath, 'utf8').trim(); | ||
|
||
if (!contributing) { | ||
file.message('contributing.md file must not be empty'); | ||
} | ||
}); |
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,42 @@ | ||
'use strict'; | ||
const execa = require('execa'); | ||
const rule = require('unified-lint-rule'); | ||
|
||
const minGitRepoAgeDays = 30; | ||
const minGitRepoAgeMs = minGitRepoAgeDays * 24 * 60 * 60 * 1000; | ||
|
||
module.exports = rule('remark-lint:awesome/git-repo-age', async (ast, file) => { | ||
const {dirname} = file; | ||
|
||
try { | ||
const firstCommitHash = await execa.stdout('git', [ | ||
'rev-list', | ||
'--max-parents=0', | ||
'HEAD' | ||
], { | ||
cwd: dirname | ||
}); | ||
|
||
const firstCommitDate = await execa.stdout('git', [ | ||
'show', | ||
'-s', | ||
'--format=%ci', | ||
firstCommitHash | ||
], { | ||
cwd: dirname | ||
}); | ||
|
||
const date = new Date(firstCommitDate); | ||
const now = new Date(); | ||
|
||
if (now - date < minGitRepoAgeMs) { | ||
file.message(`Git repository must be at least ${minGitRepoAgeDays} days old`); | ||
} | ||
} catch (err) { | ||
// Most likely not a git repository | ||
file.message(`Awesome list must reside in a valid git repository`); | ||
} | ||
}); | ||
|
||
// For stubbing | ||
module.exports.execa = execa; |
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,5 +1,11 @@ | ||
'use strict'; | ||
|
||
module.exports = [ | ||
require('./badge') | ||
require('./badge'), | ||
require('./contributing'), | ||
require('./git-repo-age'), | ||
require('./license'), | ||
require('./list-item'), | ||
require('./no-ci-badge'), | ||
require('./toc') | ||
]; |
Oops, something went wrong.