From b9b0841a69d51398b29b514bafe1cf37eaf9417b Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 25 Nov 2020 12:24:29 -0500 Subject: [PATCH] chore: Add initial Markdownlint setup --- .../markdownlint-problem-matcher.json | 17 +++ .../workflows/markdownlint-translations.yml | 50 ++++++++ .github/workflows/markdownlint.yml | 51 ++++++++ .markdownlint.json | 36 ++++++ package-lock.json | 113 ++++++++++++++++++ package.json | 7 +- 6 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/markdownlint-problem-matcher.json create mode 100644 .github/workflows/markdownlint-translations.yml create mode 100644 .github/workflows/markdownlint.yml create mode 100644 .markdownlint.json diff --git a/.github/workflows/markdownlint-problem-matcher.json b/.github/workflows/markdownlint-problem-matcher.json new file mode 100644 index 000000000000..712ff4a99231 --- /dev/null +++ b/.github/workflows/markdownlint-problem-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "markdownlint", + "pattern": [ + { + "regexp": "^([^:]*):(\\d+):?(\\d+)?\\s([\\w-\\/]*)\\s(.*)$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/markdownlint-translations.yml b/.github/workflows/markdownlint-translations.yml new file mode 100644 index 000000000000..2011c44c94a1 --- /dev/null +++ b/.github/workflows/markdownlint-translations.yml @@ -0,0 +1,50 @@ +name: Markdownlint Translations + +on: + pull_request: + branches: + - translations + push: + branches: + - translations + +jobs: + see_if_should_skip: + runs-on: ubuntu-latest + + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289 + with: + cancel_others: 'false' + github_token: ${{ github.token }} + paths: '["translations/**/*.md", "package*.json", ".markdownlint.json", ".github/workflows/markdownlint-translations.yml", ".github/workflows/markdownlint-problem-matcher.json"]' + lint: + runs-on: ubuntu-latest + needs: see_if_should_skip + if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" + + - name: Cache node modules + uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Run Markdownlint + run: | + echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json" + npm run markdownlint:translations diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml new file mode 100644 index 000000000000..54b602d4c7ba --- /dev/null +++ b/.github/workflows/markdownlint.yml @@ -0,0 +1,51 @@ +name: Markdownlint + +on: + pull_request: + branches-ignore: + - translations + push: + branches: + - main + +jobs: + see_if_should_skip: + runs-on: ubuntu-latest + + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289 + with: + cancel_others: 'false' + github_token: ${{ github.token }} + paths: '["**/*.md", "!translations/**", "package*.json", ".markdownlint.json", ".github/workflows/markdownlint.yml", ".github/workflows/markdownlint-problem-matcher.json"]' + paths_ignore: '["translations/**"]' + lint: + runs-on: ubuntu-latest + needs: see_if_should_skip + if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" + + - name: Cache node modules + uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Run Markdownlint + run: | + echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json" + npm run markdownlint diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 000000000000..5edf4d627aef --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,36 @@ +{ + "default": true, + "MD001": false, + "MD003": false, + "MD004": false, + "MD005": false, + "MD007": false, + "MD009": false, + "MD010": false, + "MD012": false, + "MD013": false, + "MD014": false, + "MD019": false, + "MD020": false, + "MD022": false, + "MD023": false, + "MD024": false, + "MD025": false, + "MD026": false, + "MD029": false, + "MD030": false, + "MD031": false, + "MD032": false, + "MD033": false, + "MD034": false, + "MD036": false, + "MD037": false, + "MD038": false, + "MD039": false, + "MD040": false, + "MD041": false, + "MD042": false, + "MD045": false, + "MD046": false, + "MD047": false +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 79090b6d986f..dd8e24bed1ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9308,6 +9308,12 @@ "has-symbols": "^1.0.1" } }, + "get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -14633,6 +14639,12 @@ "minimist": "^1.2.0" } }, + "jsonc-parser": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", + "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==", + "dev": true + }, "jsonexport": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/jsonexport/-/jsonexport-3.0.1.tgz", @@ -14753,6 +14765,15 @@ "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=" }, + "linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==", + "dev": true, + "requires": { + "uc.micro": "^1.0.1" + } + }, "linkinator": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/linkinator/-/linkinator-2.2.2.tgz", @@ -14915,6 +14936,12 @@ "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=", "dev": true }, + "lodash.differencewith": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz", + "integrity": "sha1-uvr7yRi1UVTheRdqALsK76rIVLc=", + "dev": true + }, "lodash.filter": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz", @@ -15097,6 +15124,86 @@ "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.4.tgz", "integrity": "sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==" }, + "markdown-it": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-11.0.0.tgz", + "integrity": "sha512-+CvOnmbSubmQFSA9dKz1BRiaSMV7rhexl3sngKqFyXSagoA3fBdJQ8oZWtRy2knXdpDXaBw44euz37DeJQ9asg==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "entities": "~2.0.0", + "linkify-it": "^3.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + }, + "dependencies": { + "entities": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", + "dev": true + } + } + }, + "markdownlint": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.21.1.tgz", + "integrity": "sha512-8kc88w5dyEzlmOWIElp8J17qBgzouOQfJ0LhCcpBFrwgyYK6JTKvILsk4FCEkiNqHkTxwxopT2RS2DYb/10qqg==", + "dev": true, + "requires": { + "markdown-it": "11.0.0" + } + }, + "markdownlint-cli": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.25.0.tgz", + "integrity": "sha512-pmiXJgPQtAx6YOMXPCCO3AudMWv8Gnhfrprn0raqevofOhO95nJZ6bTEXkUVbzEwvYhvGxE0Yl888aZwuRGMGw==", + "dev": true, + "requires": { + "commander": "~6.2.0", + "deep-extend": "~0.6.0", + "get-stdin": "~8.0.0", + "glob": "~7.1.6", + "ignore": "~5.1.8", + "js-yaml": "~3.14.0", + "jsonc-parser": "~2.3.1", + "lodash.differencewith": "~4.5.0", + "lodash.flatten": "~4.4.0", + "markdownlint": "~0.21.1", + "markdownlint-rule-helpers": "~0.12.0", + "minimatch": "~3.0.4", + "minimist": "~1.2.5", + "rc": "~1.2.8" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true + } + } + }, + "markdownlint-rule-helpers": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.12.0.tgz", + "integrity": "sha512-Q7qfAk+AJvx82ZY52OByC4yjoQYryOZt6D8TKrZJIwCfhZvcj8vCQNuwDqILushtDBTvGFmUPq+uhOb1KIMi6A==", + "dev": true + }, "matcher-collection": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-1.1.2.tgz", @@ -20030,6 +20137,12 @@ "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.19.tgz", "integrity": "sha512-T3PVJ6uz8i0HzPxOF9SWzWAlfN/DavlpQqepn22xgve/5QecC+XMCAtmUNnY7C9StehaV6exjUCI801lOI7QlQ==" }, + "uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "dev": true + }, "uid-safe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", diff --git a/package.json b/package.json index f776a7f9d33a..e32660a11eb7 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "jest-silent-reporter": "^0.2.1", "jest-slow-test-reporter": "^1.0.0", "make-promises-safe": "^5.1.0", + "markdownlint-cli": "^0.25.0", "mime": "^2.4.4", "mock-express-response": "^0.2.2", "nock": "^13.0.4", @@ -137,8 +138,10 @@ "rest-dev": "script/rest/update-files.js && npm run dev", "build": "cross-env NODE_ENV=production npx webpack --mode production", "start-all-languages": "cross-env NODE_ENV=development nodemon server.js", - "lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\"", - "test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps", + "lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\" && npm run markdownlint -- --fix", + "test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run markdownlint && npm run check-deps", + "markdownlint": "markdownlint \"**/*.md\" -i \"node_modules\" -i \"translations\"", + "markdownlint:translations": "markdownlint \"translations/**/*.md\"", "prebrowser-test": "npm run build", "browser-test": "start-server-and-test browser-test-server 4001 browser-test-tests", "browser-test-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en,ja' PORT=4001 node server.js",