Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location matching of contributing.md and code-of-conduct.md files #111

Merged
merged 5 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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, []);
});