Skip to content

Commit

Permalink
feat(eslint): add eslint-plugin-package-json
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Aug 13, 2024
1 parent 33d25ca commit 7f953c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/eslint/configs/jsonc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from '../../constants';
import { parserJsonc, pluginJsonc } from '../plugins';
import { parserJsonc, pluginJsonc, pluginPackageJson } from '../plugins';
import type { Config, JsoncOptions } from '../types';

export function jsonc(options: JsoncOptions = {}): Config[] {
Expand All @@ -14,6 +14,8 @@ export function jsonc(options: JsoncOptions = {}): Config[] {
plugins: {
// @ts-expect-error not matched
jsonc: pluginJsonc,
// @ts-expect-error not matched
'package-json': pluginPackageJson,
},
rules: {
// https://github.com/ota-meshi/eslint-plugin-jsonc/blob/v2.16.0/lib/configs/base.ts
Expand Down Expand Up @@ -50,6 +52,17 @@ export function jsonc(options: JsoncOptions = {}): Config[] {
'jsonc/valid-json-number': 'error',
'jsonc/vue-custom-block/no-parsing-error': 'error',

// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.15.2/src/configs/recommended.ts
'package-json/order-properties': 'error',
'package-json/repository-shorthand': 'error',
'package-json/sort-collections': 'error',
'package-json/unique-dependencies': 'error',
'package-json/valid-local-dependency': 'error',
'package-json/valid-name': 'error',
'package-json/valid-package-def': 'error',
'package-json/valid-repository-directory': 'error',
'package-json/valid-version': 'error',

...rules,
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/eslint/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as _pluginJsonc from 'eslint-plugin-jsonc';
/* @ts-expect-error missing types */
import * as _pluginMarkdown from 'eslint-plugin-markdown';
import * as _pluginN from 'eslint-plugin-n';
import * as _pluginPackageJson from 'eslint-plugin-package-json';
import * as _pluginPerfectionist from 'eslint-plugin-perfectionist';
import * as _pluginRegexp from 'eslint-plugin-regexp';
import * as _pluginTypeScript from '@typescript-eslint/eslint-plugin';
Expand Down Expand Up @@ -49,6 +50,7 @@ export const pluginJsdoc = interopDefault(_pluginJsdoc);
export const pluginJsonc = interopDefault(_pluginJsonc);
export const pluginMarkdown = interopDefault(_pluginMarkdown);
export const pluginN = interopDefault(_pluginN);
export const pluginPackageJson = interopDefault(_pluginPackageJson);
export const pluginPerfectionist = interopDefault(_pluginPerfectionist);
export const pluginRegexp = interopDefault(_pluginRegexp);
export const pluginTypeScript = interopDefault(_pluginTypeScript);
Expand Down

0 comments on commit 7f953c1

Please sign in to comment.