From d2761bbb609dcde5e1edab25088e0ccb12de40ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20de=20Vasconcelos?= Date: Tue, 1 Oct 2024 14:48:18 +0100 Subject: [PATCH] Add particular case for ordering package.json --- package.json | 42 +++++++++++++++++++++--------------------- rules/common.rule.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index a3855d6..f0f2556 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,37 @@ { "name": "@carrismetropolitana/eslint", "version": "1.0.0", - "main": "./dist/index.js", - "type": "module", - "types": "./dist/index.d.ts", - "files": [ - "dist/" - ], - "scripts": { - "start": "tsc && node dist/index.js", - "lint": "eslint .", - "build": "tsc", - "watch": "tsc -w", - "lint:fix": "eslint . --fix" - }, - "publishConfig": { - "access": "public" - }, + "author": "João de Vasconcelos", + "license": "AGPL-3.0-or-later", "homepage": "https://github.com/carrismetropolitana/eslint#readme", + "bugs": { + "url": "https://github.com/carrismetropolitana/eslint/issues" + }, "repository": { "type": "git", "url": "git+https://github.com/carrismetropolitana/eslint.git" }, - "bugs": { - "url": "https://github.com/carrismetropolitana/eslint/issues" - }, "keywords": [ "public transit", "eslint", "lint" ], - "author": "João de Vasconcelos", - "license": "AGPL-3.0-or-later", + "publishConfig": { + "access": "public" + }, + "type": "module", + "files": [ + "dist/" + ], + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "start": "tsc && node dist/index.js", + "watch": "tsc -w" + }, "dependencies": { "@eslint/compat": "1.1.1", "@eslint/js": "9.11.1", diff --git a/rules/common.rule.js b/rules/common.rule.js index a9b111e..b8fe257 100644 --- a/rules/common.rule.js +++ b/rules/common.rule.js @@ -87,4 +87,37 @@ export default tseslint.config( }, }, + { + files: ['package.json'], + rules: { + '@stylistic/comma-dangle': ['error', 'never'], + 'jsonc/auto': 'error', + 'jsonc/sort-keys': [ + 'error', + { + order: [ + 'name', + 'version', + 'author', + 'license', + 'homepage', + 'bugs', + 'repository', + 'keywords', + 'private', + 'publishConfig', + 'type', + 'files', + 'main', + 'types', + 'scripts', + 'dependencies', + 'devDependencies', + ], + pathPattern: '.*', + }, + ], + }, + }, + );