Bug 1829618 - Enable Prettier on json files (configuration changes). r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D176338
This commit is contained in:
Mark Banner 2023-05-09 16:14:52 +00:00
parent c2dd8e3266
commit baa061e133
9 changed files with 19585 additions and 9 deletions

View file

@ -11,6 +11,10 @@
!.prettierrc.js !.prettierrc.js
!.babel-eslint.rc.js !.babel-eslint.rc.js
# For now, skip all json files for ESLint, these will still be run through
# Prettier.
**/*.json
# Always ignore node_modules. # Always ignore node_modules.
**/node_modules/ **/node_modules/
@ -102,10 +106,13 @@ devtools/server/tests/xpcshell/sourcemapped.js
devtools/client/performance-new/shared/profiler_get_symbols.js devtools/client/performance-new/shared/profiler_get_symbols.js
# Testing syntax error # Testing syntax error
devtools/client/aboutdebugging/test/browser/resources/bad-extensions/invalid-json/manifest.json
devtools/client/jsonview/test/invalid_json.json
devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js
# devtools specific format test file # devtools specific format test file
devtools/server/tests/xpcshell/xpcshell_debugging_script.js devtools/server/tests/xpcshell/xpcshell_debugging_script.js
devtools/shared/webconsole/test/browser/data.json
# Generated # Generated
dom/canvas/test/webgl-conf/generated/ dom/canvas/test/webgl-conf/generated/
@ -117,6 +124,7 @@ dom/svg/test/test_SVG_namespace_ids.html
# Strange encodings # Strange encodings
dom/base/test/file_bug687859-16.js dom/base/test/file_bug687859-16.js
dom/base/test/file_bug707142_utf-16.json
dom/encoding/test/test_utf16_files.html dom/encoding/test/test_utf16_files.html
dom/encoding/test/file_utf16_be_bom.js dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js dom/encoding/test/file_utf16_le_bom.js
@ -134,6 +142,7 @@ dom/base/test/jsmodules/test_syntaxErrorInline.html
dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
dom/base/test/test_bug687859.html dom/base/test/test_bug687859.html
dom/media/webrtc/tests/mochitests/identity/idp-bad.js dom/media/webrtc/tests/mochitests/identity/idp-bad.js
dom/security/test/general/file_nonscript.json
dom/serviceworkers/test/file_js_cache_syntax_error.js dom/serviceworkers/test/file_js_cache_syntax_error.js
dom/serviceworkers/test/parse_error_worker.js dom/serviceworkers/test/parse_error_worker.js
dom/tests/mochitest/bugs/test_bug531176.html dom/tests/mochitest/bugs/test_bug531176.html
@ -160,6 +169,9 @@ js/xpconnect/tests/unit/
# Fuzzing code for testing only, targeting the JS shell # Fuzzing code for testing only, targeting the JS shell
js/src/fuzz-tests/ js/src/fuzz-tests/
# Template file
mobile/android/docs/geckoview/assets/js/search-data.json
# Uses `#filter substitution` # Uses `#filter substitution`
mobile/android/app/mobile.js mobile/android/app/mobile.js
mobile/android/app/geckoview-prefs.js mobile/android/app/geckoview-prefs.js
@ -199,9 +211,13 @@ servo/
# Test files that we don't want to lint (preprocessed, minified etc) # Test files that we don't want to lint (preprocessed, minified etc)
testing/condprofile/condprof/tests/profile testing/condprofile/condprof/tests/profile
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
testing/mozharness/configs/test/test_malformed.json
testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js
testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js
testing/talos/talos/tests/devtools/addon/content/pages/ testing/talos/talos/tests/devtools/addon/content/pages/
# Python json.
testing/talos/talos/unittests/test_talosconfig_browser_config.json
testing/talos/talos/unittests/test_talosconfig_test_config.json
# Runing Talos may extract data here, see bug 1435677. # Runing Talos may extract data here, see bug 1435677.
testing/talos/talos/tests/tp5n/ testing/talos/talos/tests/tp5n/
testing/talos/talos/fis/tp5n/ testing/talos/talos/fis/tp5n/
@ -211,8 +227,10 @@ testing/web-platform/
# toolkit/ exclusions # toolkit/ exclusions
# Intentionally invalid JS # Intentionally invalid files
toolkit/components/workerloader/tests/moduleF-syntax-error.js toolkit/components/workerloader/tests/moduleF-syntax-error.js
toolkit/components/enterprisepolicies/tests/browser/config_broken_json.json
toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_fail.json
# Built files # Built files
toolkit/components/pdfjs/content/build toolkit/components/pdfjs/content/build

View file

@ -2,14 +2,14 @@
*.* *.*
!*.js !*.js
!*.jsm !*.jsm
!*.mjs !*.json
!*.jsx !*.jsx
!*.mjs
!*.sjs !*.sjs
# Not currently enabled, but planning to soon. # Not currently enabled, but planning to soon.
# !*.html # !*.html
# !*.xhtml # !*.xhtml
# !*.json
# This should be re-enabled in bug 1827456. # This should be re-enabled in bug 1827456.
js/src/builtin js/src/builtin
@ -17,6 +17,13 @@ js/src/builtin
# Don't format README files. # Don't format README files.
README README
# Ignore build files which are used for generating toolchains. Whitespace changes
# here would trigger new toolchains.
build/build-clang/**
# Ignore testing pref files which aren't parsed normally.
testing/profiles/**/user.js
# Ignore CORS fixtures which require specific resource hashes. # Ignore CORS fixtures which require specific resource hashes.
dom/security/test/sri/script* dom/security/test/sri/script*
@ -128,10 +135,13 @@ devtools/server/tests/xpcshell/sourcemapped.js
devtools/client/performance-new/shared/profiler_get_symbols.js devtools/client/performance-new/shared/profiler_get_symbols.js
# Testing syntax error # Testing syntax error
devtools/client/aboutdebugging/test/browser/resources/bad-extensions/invalid-json/manifest.json
devtools/client/jsonview/test/invalid_json.json
devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js
# devtools specific format test file # devtools specific format test file
devtools/server/tests/xpcshell/xpcshell_debugging_script.js devtools/server/tests/xpcshell/xpcshell_debugging_script.js
devtools/shared/webconsole/test/browser/data.json
# Generated # Generated
dom/canvas/test/webgl-conf/generated/ dom/canvas/test/webgl-conf/generated/
@ -143,6 +153,7 @@ dom/svg/test/test_SVG_namespace_ids.html
# Strange encodings # Strange encodings
dom/base/test/file_bug687859-16.js dom/base/test/file_bug687859-16.js
dom/base/test/file_bug707142_utf-16.json
dom/encoding/test/test_utf16_files.html dom/encoding/test/test_utf16_files.html
dom/encoding/test/file_utf16_be_bom.js dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js dom/encoding/test/file_utf16_le_bom.js
@ -160,6 +171,7 @@ dom/base/test/jsmodules/test_syntaxErrorInline.html
dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
dom/base/test/test_bug687859.html dom/base/test/test_bug687859.html
dom/media/webrtc/tests/mochitests/identity/idp-bad.js dom/media/webrtc/tests/mochitests/identity/idp-bad.js
dom/security/test/general/file_nonscript.json
dom/serviceworkers/test/file_js_cache_syntax_error.js dom/serviceworkers/test/file_js_cache_syntax_error.js
dom/serviceworkers/test/parse_error_worker.js dom/serviceworkers/test/parse_error_worker.js
dom/tests/mochitest/bugs/test_bug531176.html dom/tests/mochitest/bugs/test_bug531176.html
@ -186,6 +198,9 @@ js/xpconnect/tests/unit/
# Fuzzing code for testing only, targeting the JS shell # Fuzzing code for testing only, targeting the JS shell
js/src/fuzz-tests/ js/src/fuzz-tests/
# Template file
mobile/android/docs/geckoview/assets/js/search-data.json
# Uses `#filter substitution` # Uses `#filter substitution`
mobile/android/app/mobile.js mobile/android/app/mobile.js
mobile/android/app/geckoview-prefs.js mobile/android/app/geckoview-prefs.js
@ -225,9 +240,13 @@ servo/
# Test files that we don't want to lint (preprocessed, minified etc) # Test files that we don't want to lint (preprocessed, minified etc)
testing/condprofile/condprof/tests/profile testing/condprofile/condprof/tests/profile
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
testing/mozharness/configs/test/test_malformed.json
testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js
testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js
testing/talos/talos/tests/devtools/addon/content/pages/ testing/talos/talos/tests/devtools/addon/content/pages/
# Python json.
testing/talos/talos/unittests/test_talosconfig_browser_config.json
testing/talos/talos/unittests/test_talosconfig_test_config.json
# Runing Talos may extract data here, see bug 1435677. # Runing Talos may extract data here, see bug 1435677.
testing/talos/talos/tests/tp5n/ testing/talos/talos/tests/tp5n/
testing/talos/talos/fis/tp5n/ testing/talos/talos/fis/tp5n/
@ -237,8 +256,10 @@ testing/web-platform/
# toolkit/ exclusions # toolkit/ exclusions
# Intentionally invalid JS # Intentionally invalid files
toolkit/components/workerloader/tests/moduleF-syntax-error.js toolkit/components/workerloader/tests/moduleF-syntax-error.js
toolkit/components/enterprisepolicies/tests/browser/config_broken_json.json
toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_fail.json
# Built files # Built files
toolkit/components/pdfjs/content/build toolkit/components/pdfjs/content/build
@ -298,6 +319,7 @@ devtools/client/shared/sourceeditor/test/codemirror/
devtools/client/shared/vendor/ devtools/client/shared/vendor/
devtools/client/inspector/markup/test/helper_diff.js devtools/client/inspector/markup/test/helper_diff.js
devtools/shared/acorn/ devtools/shared/acorn/
devtools/shared/compatibility/dataset/css-properties.json
devtools/shared/heapsnapshot/CoreDump.pb.cc devtools/shared/heapsnapshot/CoreDump.pb.cc
devtools/shared/heapsnapshot/CoreDump.pb.h devtools/shared/heapsnapshot/CoreDump.pb.h
devtools/shared/jsbeautify/ devtools/shared/jsbeautify/
@ -432,6 +454,7 @@ other-licenses/
parser/expat/ parser/expat/
remote/cdp/test/browser/chrome-remote-interface.js remote/cdp/test/browser/chrome-remote-interface.js
remote/test/puppeteer/ remote/test/puppeteer/
security/manager/tools/log_list.json
security/nss/ security/nss/
security/sandbox/chromium/ security/sandbox/chromium/
security/sandbox/chromium-shim/ security/sandbox/chromium-shim/
@ -484,21 +507,32 @@ xpcom/io/crc32c.c
############################################################################## ##############################################################################
.gradle/ .gradle/
browser/components/newtab/content-src/asrouter/schemas/BackgroundTaskMessagingExperiment.schema.json
browser/components/newtab/content-src/asrouter/schemas/MessagingExperiment.schema.json
browser/components/newtab/logs/ browser/components/newtab/logs/
browser/components/newtab/node_modules/ browser/components/newtab/node_modules/
browser/components/storybook/storybook-static/ browser/components/storybook/storybook-static/
browser/locales/l10n-changesets.json
browser/locales/l10n-onchange-changesets.json
devtools/client/aboutdebugging/test/jest/node_modules/ devtools/client/aboutdebugging/test/jest/node_modules/
devtools/client/application/test/components/node_modules/ devtools/client/application/test/components/node_modules/
devtools/client/debugger/node_modules/ devtools/client/debugger/node_modules/
dom/tests/ajax/jquery/ dom/tests/ajax/jquery/
dom/tests/ajax/mochikit/ dom/tests/ajax/mochikit/
node_modules/
intl/components/src/UnicodeScriptCodes.h intl/components/src/UnicodeScriptCodes.h
intl/unicharutil/util/nsSpecialCasingData.cpp intl/unicharutil/util/nsSpecialCasingData.cpp
intl/unicharutil/util/nsUnicodePropertyData.cpp intl/unicharutil/util/nsUnicodePropertyData.cpp
mobile/locales/l10n-changesets.json
mobile/locales/l10n-onchange-changesets.json
node_modules/
security/manager/tools/KnownRootHashes.json
security/manager/tools/PreloadedHPKPins.json
services/settings/dumps/
testing/talos/talos/tests/devtools/addon/content/pages/custom/debugger/static/js/minified.js testing/talos/talos/tests/devtools/addon/content/pages/custom/debugger/static/js/minified.js
toolkit/components/pdfjs/content/PdfJsDefaultPreferences.sys.mjs toolkit/components/pdfjs/content/PdfJsDefaultPreferences.sys.mjs
toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp
toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp
toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated
tools/browsertime/package.json
tools/browsertime/package-lock.json
try_task_config.json try_task_config.json

19501
fulllisthtmlnonutf8.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -159,7 +159,7 @@ def setup_vscode(command_context, interactive):
}, },
# Note, the top-level editor settings are left as default to allow the # Note, the top-level editor settings are left as default to allow the
# user's defaults (if any) to take effect. # user's defaults (if any) to take effect.
"[javascript][javascriptreact][typescript][typescriptreact]": { "[javascript][javascriptreact][typescript][typescriptreact][json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": True, "editor.formatOnSave": True,
}, },
@ -199,6 +199,14 @@ def setup_vscode(command_context, interactive):
"Existing settings will be lost!" "Existing settings will be lost!"
) )
# If we've got an old section with the formatting configuration, remove it
# so that we effectively "upgrade" the user to include json from the new
# settings. The user is presented with the diffs so should spot any issues.
if "[javascript][javascriptreact][typescript][typescriptreact]" in old_settings:
old_settings.pop(
"[javascript][javascriptreact][typescript][typescriptreact]"
)
settings = {**old_settings, **new_settings} settings = {**old_settings, **new_settings}
if old_settings != settings: if old_settings != settings:

View file

@ -105,8 +105,10 @@ eslint:
# Files that are likely audited. # Files that are likely audited.
- '**/*.js' - '**/*.js'
- '**/*.jsm' - '**/*.jsm'
- '**/*.json'
- '**/*.jsx' - '**/*.jsx'
- '**/*.mjs' - '**/*.mjs'
- '**/*.sjs'
- '**/*.html' - '**/*.html'
- '**/*.xhtml' - '**/*.xhtml'
- '**/*.xml' - '**/*.xml'

View file

@ -5,7 +5,7 @@ eslint:
include: ['.'] include: ['.']
exclude: [] exclude: []
# When adding to this list, consider updating hooks_js_format.py as well. # When adding to this list, consider updating hooks_js_format.py as well.
extensions: ['mjs', 'js', 'jsm', 'jsx', 'html', 'sjs', 'xhtml'] extensions: ['mjs', 'js', 'jsm', 'json', 'jsx', 'html', 'sjs', 'xhtml']
support-files: support-files:
- '**/.eslintrc.js' - '**/.eslintrc.js'
- '.eslintrc-test-paths.js' - '.eslintrc-test-paths.js'

View file

@ -33,7 +33,7 @@ def run_js_format(hooktype, changedFiles):
# No files have been touched # No files have been touched
return return
extensions = (".js", ".jsx", ".jsm", ".mjs", "sjs", "html", "xhtml") extensions = (".js", ".jsx", ".jsm", ".json", ".mjs", "sjs", "html", "xhtml")
path_list = [] path_list = []
for filename in sorted(changedFiles): for filename in sorted(changedFiles):
# Ignore files unsupported in eslint and prettier # Ignore files unsupported in eslint and prettier

View file

@ -1,19 +1,30 @@
.gradle/ .gradle/
browser/components/newtab/content-src/asrouter/schemas/BackgroundTaskMessagingExperiment.schema.json
browser/components/newtab/content-src/asrouter/schemas/MessagingExperiment.schema.json
browser/components/newtab/logs/ browser/components/newtab/logs/
browser/components/newtab/node_modules/ browser/components/newtab/node_modules/
browser/components/storybook/storybook-static/ browser/components/storybook/storybook-static/
browser/locales/l10n-changesets.json
browser/locales/l10n-onchange-changesets.json
devtools/client/aboutdebugging/test/jest/node_modules/ devtools/client/aboutdebugging/test/jest/node_modules/
devtools/client/application/test/components/node_modules/ devtools/client/application/test/components/node_modules/
devtools/client/debugger/node_modules/ devtools/client/debugger/node_modules/
dom/tests/ajax/jquery/ dom/tests/ajax/jquery/
dom/tests/ajax/mochikit/ dom/tests/ajax/mochikit/
node_modules/
intl/components/src/UnicodeScriptCodes.h intl/components/src/UnicodeScriptCodes.h
intl/unicharutil/util/nsSpecialCasingData.cpp intl/unicharutil/util/nsSpecialCasingData.cpp
intl/unicharutil/util/nsUnicodePropertyData.cpp intl/unicharutil/util/nsUnicodePropertyData.cpp
mobile/locales/l10n-changesets.json
mobile/locales/l10n-onchange-changesets.json
node_modules/
security/manager/tools/KnownRootHashes.json
security/manager/tools/PreloadedHPKPins.json
services/settings/dumps/
testing/talos/talos/tests/devtools/addon/content/pages/custom/debugger/static/js/minified.js testing/talos/talos/tests/devtools/addon/content/pages/custom/debugger/static/js/minified.js
toolkit/components/pdfjs/content/PdfJsDefaultPreferences.sys.mjs toolkit/components/pdfjs/content/PdfJsDefaultPreferences.sys.mjs
toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp
toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp
toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated
tools/browsertime/package.json
tools/browsertime/package-lock.json
try_task_config.json try_task_config.json

View file

@ -14,6 +14,7 @@ devtools/client/shared/sourceeditor/test/codemirror/
devtools/client/shared/vendor/ devtools/client/shared/vendor/
devtools/client/inspector/markup/test/helper_diff.js devtools/client/inspector/markup/test/helper_diff.js
devtools/shared/acorn/ devtools/shared/acorn/
devtools/shared/compatibility/dataset/css-properties.json
devtools/shared/heapsnapshot/CoreDump.pb.cc devtools/shared/heapsnapshot/CoreDump.pb.cc
devtools/shared/heapsnapshot/CoreDump.pb.h devtools/shared/heapsnapshot/CoreDump.pb.h
devtools/shared/jsbeautify/ devtools/shared/jsbeautify/
@ -148,6 +149,7 @@ other-licenses/
parser/expat/ parser/expat/
remote/cdp/test/browser/chrome-remote-interface.js remote/cdp/test/browser/chrome-remote-interface.js
remote/test/puppeteer/ remote/test/puppeteer/
security/manager/tools/log_list.json
security/nss/ security/nss/
security/sandbox/chromium/ security/sandbox/chromium/
security/sandbox/chromium-shim/ security/sandbox/chromium-shim/