Skip to content

Commit

Permalink
Add support for linting json files
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Nov 25, 2021
1 parent 3a2d3b9 commit dda0fbe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
20 changes: 19 additions & 1 deletion eslint-config-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
'import',
'jest',
'jest-formatting',
'jsonc',
'promise'
],
env: {
Expand Down Expand Up @@ -208,7 +209,7 @@ module.exports = {
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/semi': 'error',
'@typescript-eslint/space-before-function-paren': ['error', {
'@typescript-eslint/space-before-function-paren': ['error', {
'anonymous': 'never',
'named': 'never',
'asyncArrow': 'always'
Expand Down Expand Up @@ -237,6 +238,23 @@ module.exports = {
'jest/prefer-strict-equal': 'error',
'jest/prefer-todo': 'error'
}
},
{
files: ["*.json", "*.json5", "*.jsonc"],
parser: "jsonc-eslint-parser"
},
{
files: ["*.json"],
files: ['tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-json']
},
{
files: ["*.jsonc", 'tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-jsonc']
},
{
files: ["*.json5"],
extends: ['plugin:jsonc/recommended-with-json5']
}
],
reportUnusedDisableDirectives: true,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"eslint",
"config",
"eslint config",
"typescript"
"typescript",
"json"
],
"license": "MIT",
"dependencies": {
Expand All @@ -17,11 +18,13 @@
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-jsonc": "^2.0.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-lodash": "^7.3.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"jsonc-eslint-parser": "^2.0.4"
},
"devDependencies": {
"@types/eslint": "^8.2.0",
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ eslint-plugin-jest@^25.2.4:
dependencies:
"@typescript-eslint/experimental-utils" "^5.0.0"

eslint-plugin-jsonc@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsonc/-/eslint-plugin-jsonc-2.0.0.tgz#4e3f77da6024e63618727400b61aa2a9d3aae9ee"
integrity sha512-5UbUUvx4gUVeF9hJ+SHDW9a4OPQ8vJWu12rttQ76qGO2tlH17OC103CLq+vrmjo5VQULeVzSJ0u4s+jUATJyWQ==
dependencies:
eslint-utils "^3.0.0"
jsonc-eslint-parser "^2.0.1"
natural-compare "^1.4.0"

eslint-plugin-jsx-a11y@^6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.5.1.tgz#cdbf2df901040ca140b6ec14715c988889c2a6d8"
Expand Down Expand Up @@ -1053,6 +1062,17 @@ json5@^1.0.1:
dependencies:
minimist "^1.2.0"

jsonc-eslint-parser@^2.0.1, jsonc-eslint-parser@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-2.0.4.tgz#74f645dce020506b07f0a65cab0ff0093bf897d4"
integrity sha512-a3ZRus4qea0tSRCW2qvF/spFt7iCpdeJbiDjxbFZRZ87JCF8sI8hbxpVvUBVyZ3fLB/RQnTi+Y/yZbMlqt1BCg==
dependencies:
acorn "^8.5.0"
eslint-utils "^3.0.0"
eslint-visitor-keys "^3.0.0"
espree "^9.0.0"
semver "^7.3.5"

"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.1.tgz#720b97bfe7d901b927d87c3773637ae8ea48781b"
Expand Down

0 comments on commit dda0fbe

Please sign in to comment.