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

Bug: Support ESLint's sort-keys #75

Open
1 task
RobertAKARobin opened this issue Dec 20, 2024 · 1 comment
Open
1 task

Bug: Support ESLint's sort-keys #75

RobertAKARobin opened this issue Dec 20, 2024 · 1 comment
Labels
bug Something isn't working repro:needed This issue should include a reproducible example

Comments

@RobertAKARobin
Copy link

RobertAKARobin commented Dec 20, 2024

Environment

ESLint version: 9.17.0
@eslint/json version: 0.9.0
Node version: 20.11.0
npm version: 10.8.2
Operating System: macOS 15.1

Which language are you using?

json

What did you do?

Configuration
import json from '@eslint/json';

const sortKeys = {
	'sort-keys': [`error`, `asc`, {
		allowLineSeparatedGroups: true,
	}],
};

export default [
	{
		files: [`index.js`],
		rules: sortKeys,
	},

	{
		files: [`index.json`],
		language: `json/json`,
		plugins: {
			json,
		},
		rules: sortKeys,
	}
];

index.js

An error for sort-keys is thrown in this file as expected:

export default {
	"bbb": "bbb",
	"aaa": "aaa"
};

index.json

No sort-keys error is thrown in this file:

{
	"bbb": "bbb",
	"aaa": "aaa"
}

What did you expect to happen?

I expected a sort-keys error to be thrown because the JSON object's keys were not in alphabetical order.

What actually happened?

A sort-keys error was not thrown.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-pauaycvs?file=eslint.config.js

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

https://eslint.org/docs/latest/rules/sort-keys

@RobertAKARobin RobertAKARobin added bug Something isn't working repro:needed This issue should include a reproducible example labels Dec 20, 2024
@fasttime fasttime added this to Triage Dec 27, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Dec 27, 2024
@nzakas
Copy link
Member

nzakas commented Dec 30, 2024

sort-keys is a JavaScript-specific rule, so it can't work with JSON. We'd have to recreate a JSON-specific one.

@nzakas nzakas moved this from Needs Triage to Triaging in Triage Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working repro:needed This issue should include a reproducible example
Projects
Status: Triaging
Development

No branches or pull requests

2 participants