diff --git a/.markdownlint.autofix.json b/.markdownlint.autofix.json new file mode 100644 index 0000000000000..7bb678b286387 --- /dev/null +++ b/.markdownlint.autofix.json @@ -0,0 +1,6 @@ +{ + "default": false, + "no-trailing-spaces": { + "br_spaces": 0 + } +} diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000000000..22b99e78ddb13 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,26 @@ +{ + "commands-show-output": false, + "first-line-h1": false, + "header-increment": false, + "line-length": { + "code_blocks": false, + "tables": false, + "stern": true, + "line_length": -1 + }, + "no-bare-urls": false, + "no-blanks-blockquote": false, + "no-duplicate-header": { + "allow_different_nesting": true + }, + "no-emphasis-as-header": false, + "no-hard-tabs": { + "code_blocks": false + }, + "no-space-in-emphasis": false, + "no-trailing-punctuation": false, + "no-trailing-spaces": { + "br_spaces": 0 + }, + "single-h1": false +} diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 791d4d60bb4c8..daaef94455d90 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -92,11 +92,13 @@ session.defaultSession.getAllExtensions() ### Removed: methods in `systemPreferences` The following `systemPreferences` methods have been deprecated: + * `systemPreferences.isDarkMode()` * `systemPreferences.isInvertedColorScheme()` * `systemPreferences.isHighContrastColorScheme()` Use the following `nativeTheme` properties instead: + * `nativeTheme.shouldUseDarkColors` * `nativeTheme.shouldUseInvertedColorScheme` * `nativeTheme.shouldUseHighContrastColors` @@ -556,6 +558,7 @@ limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined ### Deprecated events in `systemPreferences` The following `systemPreferences` events have been deprecated: + * `inverted-color-scheme-changed` * `high-contrast-color-scheme-changed` @@ -573,11 +576,13 @@ nativeTheme.on('updated', () => { /* ... */ }) ### Deprecated: methods in `systemPreferences` The following `systemPreferences` methods have been deprecated: + * `systemPreferences.isDarkMode()` * `systemPreferences.isInvertedColorScheme()` * `systemPreferences.isHighContrastColorScheme()` Use the following `nativeTheme` properties instead: + * `nativeTheme.shouldUseDarkColors` * `nativeTheme.shouldUseInvertedColorScheme` * `nativeTheme.shouldUseHighContrastColors` diff --git a/docs/tutorial/devtools-extension.md b/docs/tutorial/devtools-extension.md index 377fc5c50f79e..9d06272f78fc8 100644 --- a/docs/tutorial/devtools-extension.md +++ b/docs/tutorial/devtools-extension.md @@ -32,6 +32,7 @@ Using the [React Developer Tools][react-devtools] as an example: * on macOS it is `~/Library/Application Support/Google/Chrome/Default/Extensions`. 1. Pass the location of the extension to the [`ses.loadExtension`][load-extension] API. For React Developer Tools `v4.9.0`, it looks something like: + ```javascript const { app, session } = require('electron') const path = require('path') diff --git a/package.json b/package.json index 1f19ba9af8b9d..49663a075efde 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,8 @@ "klaw": "^3.0.0", "lint": "^1.1.2", "lint-staged": "^10.2.11", + "markdownlint": "^0.21.1", + "markdownlint-cli": "^0.25.0", "minimist": "^1.2.5", "nugget": "^2.0.1", "null-loader": "^4.0.0", @@ -83,9 +85,9 @@ "lint:objc": "node ./script/lint.js --objc", "lint:py": "node ./script/lint.js --py", "lint:gn": "node ./script/lint.js --gn", - "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links && npm run lint:check-trailing-whitespace", + "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links && npm run lint:markdownlint", "lint:docs-relative-links": "python ./script/check-relative-doc-links.py", - "lint:check-trailing-whitespace": "python ./script/check-trailing-whitespace.py", + "lint:markdownlint": "markdownlint \"*.md\" \"docs/**/*.md\"", "lint:js-in-markdown": "standard-markdown docs", "create-api-json": "electron-docs-parser --dir=./", "create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --api=electron-api.json && node spec/ts-smoke/runner.js", @@ -133,7 +135,7 @@ ], "docs/api/**/*.md": [ "ts-node script/gen-filenames.ts", - "python script/check-trailing-whitespace.py --fix", + "markdownlint --config .markdownlint.auotfix.json --fix", "git add filenames.auto.gni" ], "{*.patch,.patches}": [ diff --git a/script/check-trailing-whitespace.py b/script/check-trailing-whitespace.py deleted file mode 100755 index e9cfe46097549..0000000000000 --- a/script/check-trailing-whitespace.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function, unicode_literals -import argparse -import io -import os -import sys - -SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -DOCS_DIR = os.path.join(SOURCE_ROOT, 'docs') - -def main(): - os.chdir(SOURCE_ROOT) - - args = parse_args() - - filepaths = [] - totalDirs = 0 - try: - for root, dirs, files in os.walk(DOCS_DIR): - totalDirs += len(dirs) - for f in files: - if f.endswith('.md'): - filepaths.append(os.path.join(root, f)) - except KeyboardInterrupt: - print('Keyboard interruption. Please try again.') - return - - trailingWhiteSpaceFiles = 0 - for path in filepaths: - trailingWhiteSpaceFiles += hasTrailingWhiteSpace(path, args.fix) - - print('Parsed through ' + str(len(filepaths)) + - ' files within docs directory and its ' + - str(totalDirs) + ' subdirectories.') - print('Found ' + str(trailingWhiteSpaceFiles) + - ' files with trailing whitespace.') - return trailingWhiteSpaceFiles - -def hasTrailingWhiteSpace(filepath, fix): - try: - with io.open(filepath, 'r', encoding='utf-8') as f: - lines = f.read().splitlines() - except KeyboardInterrupt: - print('Keyboard interruption while parsing. Please try again.') - return - - fixed_lines = [] - for num, line in enumerate(lines): - fixed_lines.append(line.rstrip() + '\n') - if not fix and line != line.rstrip(): - print("Trailing whitespace on line {} in file: {}".format( - num + 1, filepath)) - return True - if fix: - with io.open(filepath, 'w', newline='\n', encoding='utf-8') as f: - print(fixed_lines) - f.writelines(fixed_lines) - - return False - -def parse_args(): - parser = argparse.ArgumentParser( - description='Check for trailing whitespace in md files') - parser.add_argument('-f', '--fix', - help='Automatically fix trailing whitespace issues', - action='store_true') - return parser.parse_known_args()[0] - -if __name__ == '__main__': - sys.exit(main()) diff --git a/yarn.lock b/yarn.lock index c79bbe347f303..62689a829a166 100644 --- a/yarn.lock +++ b/yarn.lock @@ -325,6 +325,8 @@ version "3.0.1" resolved "https://registry.yarnpkg.com/@types/klaw/-/klaw-3.0.1.tgz#29f90021c0234976aa4eb97efced9cb6db9fa8b3" integrity sha512-acnF3n9mYOr1aFJKFyvfNX0am9EtPUsYPq22QUCGdJE+MVt6UyAN1jwo+PmOPqXD4K7ZS9MtxDEp/un0lxFccA== + dependencies: + "@types/node" "*" "@types/linkify-it@*": version "2.1.0" @@ -1739,6 +1741,11 @@ commander@^5.0.0, commander@^5.1.0: resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae" integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg== +commander@~6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" + integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -1998,7 +2005,7 @@ deep-eql@^3.0.1: dependencies: type-detect "^4.0.0" -deep-extend@^0.6.0: +deep-extend@^0.6.0, deep-extend@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== @@ -3266,6 +3273,11 @@ get-stdin@^7.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-7.0.0.tgz#8d5de98f15171a125c5e516643c7a6d0ea8a96f6" integrity sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ== +get-stdin@~8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53" + integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg== + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -3351,7 +3363,7 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.1.6: +glob@^7.1.6, glob@~7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -3659,7 +3671,7 @@ ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.0.0, ignore@^5.1.1, ignore@^5.1.4: +ignore@^5.0.0, ignore@^5.1.1, ignore@^5.1.4, ignore@~5.1.8: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== @@ -4196,6 +4208,14 @@ js-yaml@^3.13.1, js-yaml@^3.2.7, js-yaml@^3.6.1: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@~3.14.0: + version "3.14.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" + integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -4240,6 +4260,11 @@ json5@^2.1.2: dependencies: minimist "^1.2.5" +jsonc-parser@~2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.3.1.tgz#59549150b133f2efacca48fe9ce1ec0659af2342" + integrity sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg== + jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -4366,6 +4391,13 @@ linkify-it@^2.0.0: dependencies: uc.micro "^1.0.1" +linkify-it@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.2.tgz#f55eeb8bc1d3ae754049e124ab3bb56d97797fb8" + integrity sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ== + dependencies: + uc.micro "^1.0.1" + lint-staged@^10.2.11: version "10.2.11" resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.2.11.tgz#713c80877f2dc8b609b05bc59020234e766c9720" @@ -4506,7 +4538,12 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= -lodash.flatten@^4.4.0: +lodash.differencewith@~4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz#bafafbc918b55154e179176a00bb0aefaac854b7" + integrity sha1-uvr7yRi1UVTheRdqALsK76rIVLc= + +lodash.flatten@^4.4.0, lodash.flatten@~4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= @@ -4666,6 +4703,17 @@ markdown-extensions@^1.1.0: resolved "https://registry.yarnpkg.com/markdown-extensions/-/markdown-extensions-1.1.1.tgz#fea03b539faeaee9b4ef02a3769b455b189f7fc3" integrity sha512-WWC0ZuMzCyDHYCasEGs4IPvLyTGftYwh6wIEOULOF0HXcqZlhwRzrK0w2VUlxWA98xnvb/jszw4ZSkJ6ADpM6Q== +markdown-it@11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-11.0.0.tgz#dbfc30363e43d756ebc52c38586b91b90046b876" + integrity sha512-+CvOnmbSubmQFSA9dKz1BRiaSMV7rhexl3sngKqFyXSagoA3fBdJQ8oZWtRy2knXdpDXaBw44euz37DeJQ9asg== + dependencies: + argparse "^1.0.7" + entities "~2.0.0" + linkify-it "^3.0.1" + mdurl "^1.0.1" + uc.micro "^1.0.5" + markdown-it@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc" @@ -4682,6 +4730,38 @@ markdown-table@^1.1.0: resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60" integrity sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q== +markdownlint-cli@^0.25.0: + version "0.25.0" + resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.25.0.tgz#806b2c234259fa621af27673644506d447bdb6a1" + integrity sha512-pmiXJgPQtAx6YOMXPCCO3AudMWv8Gnhfrprn0raqevofOhO95nJZ6bTEXkUVbzEwvYhvGxE0Yl888aZwuRGMGw== + dependencies: + 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" + +markdownlint-rule-helpers@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.12.0.tgz#c41d9b990c50911572e8eb2fba3e6975a5514b7e" + integrity sha512-Q7qfAk+AJvx82ZY52OByC4yjoQYryOZt6D8TKrZJIwCfhZvcj8vCQNuwDqILushtDBTvGFmUPq+uhOb1KIMi6A== + +markdownlint@^0.21.1, markdownlint@~0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.21.1.tgz#9442afcf12bf65ce9d613212028cf85741677421" + integrity sha512-8kc88w5dyEzlmOWIElp8J17qBgzouOQfJ0LhCcpBFrwgyYK6JTKvILsk4FCEkiNqHkTxwxopT2RS2DYb/10qqg== + dependencies: + markdown-it "11.0.0" + matcher-collection@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/matcher-collection/-/matcher-collection-1.1.2.tgz#1076f506f10ca85897b53d14ef54f90a5c426838" @@ -4895,7 +4975,7 @@ minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0, minimist@~1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= -minimist@^1.2.5: +minimist@^1.2.5, minimist@~1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -5973,7 +6053,7 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -rc@^1.1.0, rc@^1.2.7: +rc@^1.1.0, rc@^1.2.7, rc@~1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==