Lint package.json files (#3368)

Notable changes in this context:

- simplification of the ESLint calls - there is no longer a combination
of two file/directory lists (one in `package.json` and one in
`.eslintignore`)
- removal of a non-existent path from the `.eslintignore`
- use shorthand declaration for GitHub repository

Normally the new plugin would also sort the scripts in the package.json
alphabetically, but I think the current order is fine, so I deactivated
it.

Is it overkill to introduce a linter plugin just for the `package.json`
files?

In other projects I have seen that such internal changes were marked
with "chore" in the changelog. That's what I've done here. These chore
changes are less interesting for "normal" users.

Please feel free to give me feedback.
This commit is contained in:
Kristjan ESPERANTO
2024-01-24 20:43:59 +01:00
committed by GitHub
parent f88b92fb1f
commit b0161fe011
10 changed files with 146 additions and 17 deletions

View File

@@ -1 +1,2 @@
modules/default/calendar/vendor/*
modules/*
!modules/default/

View File

@@ -79,6 +79,15 @@
"rules": {
"@stylistic/quotes": "off"
}
},
{
"extends": ["plugin:package-json/recommended"],
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"plugins": ["package-json"],
"rules": {
"package-json/sort-collections": ["error", ["devDependencies", "dependencies", "peerDependencies", "config"]]
}
}
]
}

View File

@@ -1,4 +1,5 @@
*.js
.eslintignore
.prettierignore
/config
/coverage

View File

@@ -12,6 +12,7 @@ _This release is scheduled to be released on 2024-04-01._
### Added
- Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64
- [chore] Add `eslint-plugin-package-json` to lint the `package.json` files
### Updated

View File

@@ -1,10 +1,12 @@
{
"name": "magicmirror-fonts",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "magicmirror-fonts",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@fontsource/roboto": "^5.0.8",

View File

@@ -1,10 +1,8 @@
{
"name": "magicmirror-fonts",
"description": "Package for fonts use by MagicMirror² Core.",
"repository": {
"type": "git",
"url": "git+https://github.com/MagicMirrorOrg/MagicMirror.git"
},
"version": "1.0.0",
"description": "Package for fonts use by MagicMirror² core.",
"repository": "MagicMirrorOrg/MagicMirror",
"license": "MIT",
"bugs": {
"url": "https://github.com/MagicMirrorOrg/MagicMirror/issues"

119
package-lock.json generated
View File

@@ -32,6 +32,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-package-json": "^0.10.0",
"eslint-plugin-unicorn": "^50.0.1",
"express-basic-auth": "^1.2.1",
"husky": "^8.0.3",
@@ -2055,6 +2056,16 @@
"@types/node": "*"
}
},
"node_modules/@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==",
"dev": true,
"dependencies": {
"@types/minimatch": "*",
"@types/node": "*"
}
},
"node_modules/@types/graceful-fs": {
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
@@ -2115,6 +2126,12 @@
"@types/node": "*"
}
},
"node_modules/@types/minimatch": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz",
"integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.19.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.7.tgz",
@@ -2973,6 +2990,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/builtins": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",
"integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",
"dev": true,
"dependencies": {
"semver": "^7.0.0"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@@ -3765,6 +3791,15 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/detect-indent": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz",
"integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/detect-newline": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz",
@@ -4570,6 +4605,25 @@
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0"
}
},
"node_modules/eslint-plugin-package-json": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-package-json/-/eslint-plugin-package-json-0.10.0.tgz",
"integrity": "sha512-vUEfGptdpaEw0DTzN8Yl4cjZ2XZosuzAbZ+kOKJN+tJRe2hZDogesMhNYT8FI26QZ1rYUnfQ0wwzBTjswGr04g==",
"dev": true,
"dependencies": {
"package-json-validator": "^0.6.3",
"semver": "^7.5.4",
"sort-package-json": "^1.57.0",
"validate-npm-package-name": "^5.0.0"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"eslint": ">=8.0.0",
"jsonc-eslint-parser": "^2.0.0"
}
},
"node_modules/eslint-plugin-unicorn": {
"version": "50.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-50.0.1.tgz",
@@ -6114,6 +6168,15 @@
"node": ">=8"
}
},
"node_modules/is-plain-obj": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
"integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
@@ -7027,6 +7090,25 @@
"node": ">=6"
}
},
"node_modules/jsonc-eslint-parser": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/jsonc-eslint-parser/-/jsonc-eslint-parser-2.4.0.tgz",
"integrity": "sha512-WYDyuc/uFcGp6YtM2H0uKmUwieOuzeE/5YocFJLnLfclZ4inf3mRn8ZVy1s7Hxji7Jxm6Ss8gqpexD/GlKoGgg==",
"dev": true,
"peer": true,
"dependencies": {
"acorn": "^8.5.0",
"eslint-visitor-keys": "^3.0.0",
"espree": "^9.0.0",
"semver": "^7.3.5"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ota-meshi"
}
},
"node_modules/jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
@@ -8075,6 +8157,31 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/optimist": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
"integrity": "sha512-snN4O4TkigujZphWLN0E//nQmm7790RYaE53DdL7ZYwee2D8DDo9/EyYiKUfN3rneWUjhJnueija3G9I2i0h3g==",
"dev": true,
"dependencies": {
"minimist": "~0.0.1",
"wordwrap": "~0.0.2"
}
},
"node_modules/optimist/node_modules/minimist": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"integrity": "sha512-iotkTvxc+TwOm5Ieim8VnSNvCDjCK9S8G3scJ50ZthspSxa7jx50jkhYduuAtAjvfDUwSgOwf8+If99AlOEhyw==",
"dev": true
},
"node_modules/optimist/node_modules/wordwrap": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
"integrity": "sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==",
"dev": true,
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/optionator": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
@@ -11082,6 +11189,18 @@
"spdx-license-ids": "^3.0.0"
}
},
"node_modules/validate-npm-package-name": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz",
"integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==",
"dev": true,
"dependencies": {
"builtins": "^5.0.0"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",

View File

@@ -18,20 +18,17 @@
"test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit",
"test:unit": "NODE_ENV=test jest --selectProjects unit",
"test:prettier": "prettier . --check",
"test:js": "eslint 'js/**/*.js' 'modules/default/**/*.js' 'clientonly/*.js' 'serveronly/*.js' 'translations/*.js' 'vendor/*.js' 'tests/**/*.js' 'config/*'",
"test:js": "eslint .",
"test:css": "stylelint 'css/main.css' 'fonts/*.css' 'modules/default/**/*.css' 'vendor/*.css' --config .stylelintrc.json",
"test:calendar": "node ./modules/default/calendar/debug.js",
"config:check": "node js/check_config.js",
"lint:prettier": "prettier . --write",
"lint:js": "eslint 'js/**/*.js' 'modules/default/**/*.js' 'clientonly/*.js' 'serveronly/*.js' 'translations/*.js' 'vendor/*.js' 'tests/**/*.js' 'config/*' --fix",
"lint:js": "eslint . --fix",
"lint:css": "stylelint 'css/main.css' 'fonts/*.css' 'modules/default/**/*.css' 'vendor/*.css' --config .stylelintrc.json --fix",
"lint:staged": "lint-staged",
"prepare": "[ -f node_modules/.bin/husky ] && husky install || echo no husky installed."
},
"repository": {
"type": "git",
"url": "git+https://github.com/MagicMirrorOrg/MagicMirror.git"
},
"repository": "MagicMirrorOrg/MagicMirror",
"keywords": [
"magic mirror",
"magicmirror",
@@ -53,6 +50,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-package-json": "^0.10.0",
"eslint-plugin-unicorn": "^50.0.1",
"express-basic-auth": "^1.2.1",
"husky": "^8.0.3",

2
vendor/package-lock.json generated vendored
View File

@@ -1,10 +1,12 @@
{
"name": "magicmirror-vendors",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "magicmirror-vendors",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.5.1",

8
vendor/package.json vendored
View File

@@ -1,10 +1,8 @@
{
"name": "magicmirror-vendors",
"description": "Package for vendors use by MagicMirror² Core.",
"repository": {
"type": "git",
"url": "git+https://github.com/MagicMirrorOrg/MagicMirror.git"
},
"version": "1.0.0",
"description": "Package for vendors use by MagicMirror² core.",
"repository": "MagicMirrorOrg/MagicMirror",
"license": "MIT",
"bugs": {
"url": "https://github.com/MagicMirrorOrg/MagicMirror/issues"