Skip to content

Commit

Permalink
Fix location matching of contributing.md and code-of-conduct.md files (
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Jul 27, 2020
1 parent a0d9240 commit 4e0aead
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const lint = options => {
plugins: options.config
}];

const codeOfConductFile = globby.sync(['{.github/,}{code-of-conduct,code_of_conduct}.md'], {nocase: true, cwd: dirname})[0];
const codeOfConductFile = globby.sync(['{code-of-conduct,code_of_conduct}.md', '.github/{code-of-conduct,code_of_conduct}.md'], {nocase: true, cwd: dirname})[0];
if (codeOfConductFile) {
const codeOfConductVFile = toVfile.readSync(path.resolve(dirname, codeOfConductFile));
codeOfConductVFile.repoURL = options.repoURL;
Expand Down
2 changes: 1 addition & 1 deletion rules/contributing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const rule = require('unified-lint-rule');
module.exports = rule('remark-lint:awesome-contributing', (ast, file) => {
const {dirname} = file;

const contributingFile = globby.sync(['{.github/,}contributing.md'], {nocase: true, cwd: dirname})[0];
const contributingFile = globby.sync(['contributing.md', '.github/contributing.md'], {nocase: true, cwd: dirname})[0];
// TODO: This doesn't work on Linux for some reason. Investigate and then open an issue on `fast-glob`.
// const contributingFile = globby.sync('contributing.md', {case: false, cwd: dirname})[0];

Expand Down
30 changes: 30 additions & 0 deletions test/fixtures/contributing/valid2/.github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contribution Guidelines

Please note that this project is released with a [Contributor Code of Conduct](code-of-conduct.md). By participating in this project you agree to abide by its terms.

---

Ensure your pull request adheres to the following guidelines:

- **If you just created something, wait at least 7 days before submitting.** This is to give it some time to mature and ensure it's not just a publish-and-forget type of project.
- If you submit a project that is similar to an existing project in the list, argue how it's better.
- Search previous suggestions before making a new one, as yours may be a duplicate.
- Suggested packages should be tested and documented.
- Make an individual pull request for each suggestion.
- Use the following format: `[package](link) - Description.`
- Additions should be added to the bottom of the relevant category.
- Link to the GitHub repo, not npmjs.com.
- Keep descriptions short and simple, but descriptive.
- Don't mention `Node.js` in the description as it's implied.
- Start the description with a capital and end with a full stop/period.
- Don't start the description with `A` or `An`.
- Check your spelling and grammar.
- Make sure your text editor is set to remove trailing whitespace.
- The pull request should have a useful title and include a link to the package and why it should be included.
- New categories or improvements to the existing categorization are welcome, but should be done in a separate pull request.

Thank you for your suggestions!

### Updating your PR

A lot of times, making a PR adhere to the standards above can be difficult. If the maintainers notice anything that we'd like changed, we'll ask you to edit your PR before we merge it. If you're not sure how to do that, [here is a guide](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md) on the different ways you can update your PR so that we can merge it.
Empty file.
30 changes: 30 additions & 0 deletions test/fixtures/contributing/valid3/.github/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contribution Guidelines

Please note that this project is released with a [Contributor Code of Conduct](code-of-conduct.md). By participating in this project you agree to abide by its terms.

---

Ensure your pull request adheres to the following guidelines:

- **If you just created something, wait at least 7 days before submitting.** This is to give it some time to mature and ensure it's not just a publish-and-forget type of project.
- If you submit a project that is similar to an existing project in the list, argue how it's better.
- Search previous suggestions before making a new one, as yours may be a duplicate.
- Suggested packages should be tested and documented.
- Make an individual pull request for each suggestion.
- Use the following format: `[package](link) - Description.`
- Additions should be added to the bottom of the relevant category.
- Link to the GitHub repo, not npmjs.com.
- Keep descriptions short and simple, but descriptive.
- Don't mention `Node.js` in the description as it's implied.
- Start the description with a capital and end with a full stop/period.
- Don't start the description with `A` or `An`.
- Check your spelling and grammar.
- Make sure your text editor is set to remove trailing whitespace.
- The pull request should have a useful title and include a link to the package and why it should be included.
- New categories or improvements to the existing categorization are welcome, but should be done in a separate pull request.

Thank you for your suggestions!

### Updating your PR

A lot of times, making a PR adhere to the standards above can be difficult. If the maintainers notice anything that we'd like changed, we'll ask you to edit your PR before we merge it. If you're not sure how to do that, [here is a guide](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md) on the different ways you can update your PR so that we can merge it.
Empty file.
10 changes: 10 additions & 0 deletions test/rules/contributing.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ test('contributing - valid contributing.md', async t => {
const messages = await lint({config, filename: 'test/fixtures/contributing/valid1/readme.md'});
t.deepEqual(messages, []);
});

test('contributing - valid .github/CONTRIBUTING.md', async t => {
const messages = await lint({config, filename: 'test/fixtures/contributing/valid2/readme.md'});
t.deepEqual(messages, []);
});

test('contributing - valid .github/contributing.md', async t => {
const messages = await lint({config, filename: 'test/fixtures/contributing/valid3/readme.md'});
t.deepEqual(messages, []);
});

0 comments on commit 4e0aead

Please sign in to comment.