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

[core] cross-os jsonlint #19377

Merged
merged 2 commits into from
Jan 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
command: yarn lint:ci
- run:
name: Lint JSON
command: yarn jsonlint
command: yarn --silent jsonlint
test_types:
<<: *defaults
steps:
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"docs:typescript:formatted": "yarn workspace docs typescript:transpile",
"docs:mdicons:synonyms": "babel-node --config-file ./babel.config.js ./docs/scripts/updateIconSynonyms",
"framer:build": "yarn workspace framer build",
"jsonlint": "yarn --silent jsonlint:files | xargs -n1 jsonlint -q -c && echo \"jsonlint: no lint errors\"",
"jsonlint:files": "find . -name \"*.json\" | grep -v -f .eslintignore",
"jsonlint": "node scripts/jsonlint.js",
"lint": "eslint . --cache --report-unused-disable-directives",
"lint:ci": "eslint . --report-unused-disable-directives",
"lint:fix": "eslint . --cache --fix",
Expand Down Expand Up @@ -79,6 +78,7 @@
"babel-plugin-transform-react-remove-prop-types": "^0.4.21",
"chai": "^4.1.2",
"chai-dom": "^1.8.1",
"chalk": "^3.0.0",
"compression-webpack-plugin": "^3.0.0",
"confusing-browser-globals": "^1.0.9",
"cross-env": "^6.0.0",
Expand All @@ -102,7 +102,6 @@
"glob": "^7.1.2",
"glob-gitignore": "^1.0.11",
"jsdom": "^16.0.0",
"jsonlint": "^1.6.3",
"karma": "^4.3.0",
"karma-browserstack-launcher": "~1.4.0",
"karma-chrome-launcher": "^3.0.0",
Expand Down
44 changes: 44 additions & 0 deletions scripts/jsonlint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-disable no-console */
const chalk = require('chalk');
const fse = require('fs-extra');
const glob = require('glob-gitignore');
const path = require('path');

const passMessage = message => `✓ ${chalk.gray(message)}`;
const failMessage = message => `✗ ${chalk.whiteBright(message)}`;

async function run() {
const workspaceRoot = path.resolve(__dirname, '..');

const eslintignoreContent = await fse.readFile(path.join(workspaceRoot, '.eslintignore'), {
encoding: 'utf8',
});
const eslintignore = eslintignoreContent.split(/\r?\n/).slice(0, -1);

const filenames = glob.sync('**/*.json', {
cwd: workspaceRoot,
ignore: eslintignore,
});

let passed = true;
const checks = filenames.map(async filename => {
const content = await fse.readFile(path.join(workspaceRoot, filename), { encoding: 'utf8' });
try {
JSON.parse(content);
console.log(passMessage(filename));
} catch (error) {
passed = false;
console.error(failMessage(`Error parsing ${filename}:\n\n${String(error)}`));
}
});

await Promise.all(checks);
if (passed === false) {
throw new Error('At least one file did not pass. Check the console output');
}
}

run().catch(error => {
console.error(error);
process.exit(1);
});
62 changes: 10 additions & 52 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2677,11 +2677,6 @@ JSONStream@^1.0.4, JSONStream@^1.3.4:
jsonparse "^1.2.0"
through ">=2.2.7 <3"

JSV@^4.0.x:
version "4.0.2"
resolved "https://registry.yarnpkg.com/JSV/-/JSV-4.0.2.tgz#d077f6825571f82132f9dffaed587b4029feff57"
integrity sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=

abab@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a"
Expand Down Expand Up @@ -2957,19 +2952,14 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"

ansi-styles@^4.0.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.0.tgz#5681f0dcf7ae5880a7841d8831c4724ed9cc0172"
integrity sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg==
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
dependencies:
"@types/color-name" "^1.1.1"
color-convert "^2.0.1"

ansi-styles@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.0.0.tgz#cb102df1c56f5123eab8b67cd7b98027a0279178"
integrity sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg=

any-promise@^1.0.0, any-promise@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
Expand Down Expand Up @@ -4228,14 +4218,13 @@ chalk@^1.0.0, chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
integrity sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=
chalk@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
dependencies:
ansi-styles "~1.0.0"
has-color "~0.1.0"
strip-ansi "~0.1.0"
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chardet@^0.7.0:
version "0.7.0"
Expand Down Expand Up @@ -7644,11 +7633,6 @@ has-binary2@~1.0.2:
dependencies:
isarray "2.0.1"

has-color@~0.1.0:
version "0.1.7"
resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f"
integrity sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8=

[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39"
Expand Down Expand Up @@ -8931,14 +8915,6 @@ jsonify@~0.0.0:
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=

jsonlint@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/jsonlint/-/jsonlint-1.6.3.tgz#cb5e31efc0b78291d0d862fbef05900adf212988"
integrity sha512-jMVTMzP+7gU/IyC6hvKyWpUU8tmTkK5b3BPNuMI9U8Sit+YAWLlZwB6Y6YrdCxfg2kNz05p3XY3Bmm4m26Nv3A==
dependencies:
JSV "^4.0.x"
nomnom "^1.5.x"

jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
Expand Down Expand Up @@ -10596,14 +10572,6 @@ node-releases@^1.1.44:
dependencies:
semver "^6.3.0"

nomnom@^1.5.x:
version "1.8.1"
resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.8.1.tgz#2151f722472ba79e50a76fc125bb8c8f2e4dc2a7"
integrity sha1-IVH3Ikcrp55Qp2/BJbuMjy5Nwqc=
dependencies:
chalk "~0.4.0"
underscore "~1.6.0"

[email protected]:
version "1.0.10"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
Expand Down Expand Up @@ -14090,11 +14058,6 @@ strip-ansi@^6.0.0:
dependencies:
ansi-regex "^5.0.0"

strip-ansi@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.1.1.tgz#39e8a98d044d150660abe4a6808acf70bb7bc991"
integrity sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=

strip-bom@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e"
Expand Down Expand Up @@ -14815,11 +14778,6 @@ umask@^1.1.0:
resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d"
integrity sha1-8pzr8B31F5ErtY/5xOUP3o4zMg0=

underscore@~1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8"
integrity sha1-izixDKze9jM3uLJOT/htRa6lKag=

[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db"
Expand Down