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

Prettier 3.2.3 incorrectly formats .estlintrc.json #15946

Closed
fstaffa opened this issue Jan 17, 2024 · 4 comments
Closed

Prettier 3.2.3 incorrectly formats .estlintrc.json #15946

fstaffa opened this issue Jan 17, 2024 · 4 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@fstaffa
Copy link

fstaffa commented Jan 17, 2024

After updating to prettier 3.2.3, it formats .eslintrc.json with trailing commas, here is an example:

{
	"parser": "@typescript-eslint/parser",
	"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
	"plugins": ["no-only-tests"],
	"parserOptions": {
		"ecmaVersion": 2018,
		"sourceType": "module", <--
	},
	"ignorePatterns": ["node_modules/", "build"],
	"rules": {
		"no-console": ["off"],
		"@typescript-eslint/consistent-type-assertions": [
			"error",
			{
				"assertionStyle": "angle-bracket", <--
			}, <--
		],
		"@typescript-eslint/no-explicit-any": "off",
		"@typescript-eslint/no-var-requires": "off",
		"@typescript-eslint/explicit-function-return-type": "off",
		"@typescript-eslint/no-use-before-define": "off",
		"@typescript-eslint/no-empty-function": "off",
		"prefer-const": "off",
		"no-only-tests/no-only-tests": ["error"], <--
	}, <--
}

When running eslint 8.56.0, it throw an error
Cannot read config file: [foldername]/.eslintrc.json Error: Unexpected token } in JSON at position 210

I assume this is related to #15881 , and that it incorrectly identifies which files are json and which jsonc. While eslint config specifies it allows comments, I am not sure it implies it also accepts trailing commas https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-formats

[Edit]: Here are minimal replication steps:

  1. checkout https://github.com/fstaffa/prettier-eslintrc-issue
  2. run npm ci
  3. run npm run eslint (works as exptected)
  4. run npm run prettier (changes .eslintrc.json)
  5. run npm run eslint (fails with error similar to what was reported above)
@henrikvolmer
Copy link

We have the same issue. Please revert #15927 or fix the problem.

@fisker
Copy link
Member

fisker commented Jan 17, 2024

Close in favor of #15946

@fisker fisker closed this as completed Jan 17, 2024
@fstaffa
Copy link
Author

fstaffa commented Jan 17, 2024

I think you meant #15945

@fisker
Copy link
Member

fisker commented Jan 17, 2024

Yes, thank you!

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Apr 18, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants