diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..fd16fce --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @github/accessibility-reviewers diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..8044ebe --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at opensource@github.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5f9e342 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index b9d1a8d..2b7193a 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,12 @@ -# GitHub Flavored Markdown Linting +# Markdownlint-github -We are using the [`markdownlint`](https://github.com/DavidAnson/markdownlint) library (via [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) and adding our opinions and custom rules to it. - -To review behaviors supported by `markdownlint`, particularly how to enable or disable rules, see [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration). +This repository provides GitHub's recommended [`markdownlint`](https://github.com/DavidAnson/markdownlint) configurations, and additional rules for use on GitHub open source and internal projects. ## Opinions -At GitHub, we have opinions about how our markdown should be written. - In addition to defaults defined by `markdownlint`, we use this repository to enforce rules not defined by default, including our own custom rules. -See our opinions codified in [index.js](./index.js). - -### Should I disable rules enabled by this plugin? - -This plugin will enable the defaults defined by `markdownlint`. Several of these pertain to stylistic practices. You may choose to disable these rules if you determine it doesn't provide value for your project. - -However, others of these rules should **NOT** be disabled because they encourage best accessibility practices. Disabling these rules will negatively impact accessibility. These rules are specified in [accessibility.json](./accessibility.json). +See opinions codified in [index.js](./index.js). ## Rules @@ -29,19 +19,20 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali ## Usage -**Note**: We recommend configuring [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) over `markdownlint-cli` for compatibility with the [vscode-markdownlint](https://github.com/DavidAnson/vscode-markdownlint) plugin. +**Important**: We support the use of `markdownlint` through [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) instead of `markdownlint-cli` for compatibility with the [`vscode-markdownlint`](https://github.com/DavidAnson/vscode-markdownlint) plugin. -1. Create a `.markdownlint-cli2.cjs` file in the root of your repository +1. Create a `.markdownlint-cli2.cjs` file in the root of your repository. ```bash touch .markdownlint-cli2.cjs ``` -2. Install packages +2. Install packages. - ```bash npm install -D markdownlint-cli2 # if updating existing package, check for updates npm install -D @github/markdownlint-github [--@github:registry=https://registry.npmjs.org] + npm install -D markdownlint-cli2-formatter-pretty ``` 3. Add/modify your linting script in `package.json`. @@ -57,22 +48,39 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali module.exports = { config: options, customRules: ["@github/markdownlint-github"], + outputFormatters: [ + [ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation + ] } ``` - Or, you can also pass in configuration options that you wish to override the default. This looks like: + Or, you can also pass in configuration options that you wish to override the default. Read more at [Customizing configurations](#customizing-configurations). + This looks like: ```js const options = require('@github/markdownlint-github').init({ - 'fenced-code-language': false, + 'fenced-code-language': false, // Custom overrides }) module.exports = { config: options, customRules: ["@github/markdownlint-github"], + outputFormatters: [ + [ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] + ] } ``` -5. Install the [`vscode-markdownlint`](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) plugin to ensure `markdownlint` violations are surfaced in the file. This plugin should flag rules based off your `.markdownlint-cli2.cjs` configuration. When you make edits to your configuartion, you will need to reload the VSCode window (`Ctrl+Shift+P` -> `Reload Window`) to ensure the extension syncs. +5. Install the [`vscode-markdownlint`](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) plugin to ensure `markdownlint` violations are surfaced in the file. This plugin should flag rules based off your `.markdownlint-cli2.cjs` configuration. When you make edits to your configuration, you will need to reload the VSCode window (`Ctrl+Shift+P` -> `Reload Window`) to ensure the extension syncs. If your project runs on Codespaces, consider adding this extension to your `.devcontainer/devcontainer.json` so that this extension is installed to new Codespaces by default. + +### Customizing configurations + +You may determine that the defaults set by this plugin are not suitable for your project. + +This plugin will pull in the the defaults defined by `markdownlint`, several of which pertain to stylistic practices. You may choose to disable these rules if you determine it doesn't provide value for your project. + +However, others of these rules should **NOT** be disabled because they encourage best accessibility practices. Disabling these rules will negatively impact accessibility. These rules are defined in [accessibility.json](./style/accessibility.json). + +To review configurations supported by `markdownlint`, see [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration). ### Advanced: Adding custom rules in your codebase @@ -91,6 +99,14 @@ See [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownli Consider upstreaming any rules you find useful as proposals to this repository. +## License + +This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms. + +## Maintainers + +See [CODEOWNERS](./CODEOWNERS). + ## Contributing Please read [Contributing Guide](./CONTRIBUTING.md) for more information. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..6cbd393 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,31 @@ +# Security + +Thanks for helping make GitHub safe for everyone. + +GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub). + +Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we will ensure that your finding gets passed along to the appropriate maintainers for remediation. + +## Reporting Security Issues + +If you believe you have found a security vulnerability in any GitHub-owned repository, please report it to us through coordinated disclosure. + +**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.** + +Instead, please send an email to opensource-security[@]github.com. + +Please include as much of the information listed below as you can to help us better understand and resolve the issue: + + * The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Policy + +See [GitHub's Safe Harbor Policy](https://docs.github.com/en/github/site-policy/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms) \ No newline at end of file diff --git a/SUPPORT.md b/SUPPORT.md new file mode 100644 index 0000000..dcc2e92 --- /dev/null +++ b/SUPPORT.md @@ -0,0 +1,13 @@ +# Support + +## How to file issues and get help + +This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue. + +For help or questions about using this project, please file an issue. + +**markdownlint-github** is under active development and maintained by GitHub staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner. + +## GitHub Support Policy + +Support for this project is limited to the resources listed above. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a044ff9..95c9ee1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4173,9 +4173,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -5465,9 +5465,9 @@ } }, "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -8889,9 +8889,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "jsx-ast-utils": { @@ -9831,9 +9831,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" diff --git a/package.json b/package.json index b0b3cf4..b5b0ffc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@github/markdownlint-github", "version": "0.1.0", - "description": "", + "description": "An opinionated collection of markdownlint rules used by GitHub.", "main": "index.js", "directories": { "test": "test" diff --git a/src/rules/no-default-alt-text.js b/src/rules/no-default-alt-text.js index 78b02b2..083f86d 100644 --- a/src/rules/no-default-alt-text.js +++ b/src/rules/no-default-alt-text.js @@ -1,12 +1,14 @@ // Regex to match alt text that is the same as the default image filename // e.g. "Screen Shot 2020-10-20 at 2 52 27 PM" // e.g. "Screenshot 2020-10-20 at 2 52 27 PM" +// e.g. "Clean Shot 2020-10-20 @45x" +// e.g. "image" const defaultMacOsScreenshotMarkdownRegex = - /^Screen ?[S|s]hot \d{4}-\d{2}-\d{2} at \d \d{2} \d{2} [A|P]M$/gi; + /^(Screen|Clean) ?[S|s]hot \d{4}-\d{2}-\d{2}/gi; const imageMarkdownRegex = /^image$/i; const defaultMacOsScreenshotHtmlRegex = - /alt="Screen ?[S|s]hot \d{4}-\d{2}-\d{2} at \d \d{2} \d{2} [A|P]M"/gi; + /alt="(Screen|Clean) ?[S|s]hot \d{4}-\d{2}-\d{2}/gi; const imageHtmlRegex = /alt="image"/i; module.exports = { diff --git a/test/no-default-alt-text.test.js b/test/no-default-alt-text.test.js index e4f4e64..63c55ca 100644 --- a/test/no-default-alt-text.test.js +++ b/test/no-default-alt-text.test.js @@ -33,6 +33,7 @@ describe("GH001: No Default Alt Text", () => { "![ScreenShot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)", "![Screen shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)", "![Screenshot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)", + "![Clean Shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)", "![image](https://user-images.githubusercontent.com/abcdef.png)", "![Image](https://user-images.githubusercontent.com/abcdef.png)", ]; @@ -44,7 +45,7 @@ describe("GH001: No Default Alt Text", () => { .flat() .filter((name) => !name.includes("GH")); - expect(failedRules).toHaveLength(6); + expect(failedRules).toHaveLength(7); for (const rule of failedRules) { expect(rule).toBe("no-default-alt-text"); } @@ -56,6 +57,7 @@ describe("GH001: No Default Alt Text", () => { 'ScreenShot 2022-06-26 at 7 41 30 PM', 'Screen shot 2022-06-26 at 7 41 30 PM', 'Screenshot 2022-06-26 at 7 41 30 PM', + 'Clean Shot 2022-06-26 at 7 41 30 PM', 'Image', 'image', ]; @@ -67,7 +69,7 @@ describe("GH001: No Default Alt Text", () => { .flat() .filter((name) => !name.includes("GH")); - expect(failedRules).toHaveLength(6); + expect(failedRules).toHaveLength(7); for (const rule of failedRules) { expect(rule).toBe("no-default-alt-text"); }