-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Story] Check ESLint consistency between IDE and CLI output #2789
Comments
ESLint extension for VS CodeIt's active by default but it's not specifically defined in VS Code config file, which we should do. Here is information from the extension:
Observation:
EDIT: I downgraded eslint in the workspace and rebuilt the dev container. I can confirm that the ESLint extension for VS Code is using the eslint binary installed in the workspace. ESLint extension for VS Code output when opening a TS file:
This confirms what the ESLint docs says:
Remaining questions:
node version does not match that in terminalAccording to this comment:
The same post should provide the solution:
UPDATE: It's not clear whether setting the runtime or nodePath is applied. The plugin shows this error message if the path to node is incorrect. But the output below also shows that the version of node printed is still the one shipped with VS Code. When setting
For now I will let the ESLint server use the node version shipped with VS Code to avoid increasing the complexity of the workspace without confirmed benefits. |
Format on SaveCurrently, ESLint is formatting TS files on save, though this is something I would like to configure specifically. The formatter feature of the ESLint extension controlled by ESLint does not respect this config (it will still format on save):
This section describes how to enable and disable auto fix: https://github.com/microsoft/vscode-eslint?tab=readme-ov-file#version-204 This comment from the author of the extension suggest an ESLint package to use to format JSON files: microsoft/vscode-eslint#1173 (comment) |
Format JSON files with ESLint-PrettierThis ESLint configuration work to format the files
{
"root": true,
"overrides": [
{
"files": ["*.json", "*.jsonc", "*.json5", ".vscode/test.json"],
"parser": "jsonc-eslint-parser",
"extends": ["plugin:prettier/recommended"],
"rules": {}
}
]
} Example: Saving the file will format it thanks to the VS Code configuration we have previously identified. IssueThe file EDIT: Renaming Solution: https://stackoverflow.com/a/59651542 (it works) |
|
Formatting Vs LintingPrettier is a formatter. ESLint is a linter. According to this thread, ESLint tried to do both formatting and linting, but is now focusing on linting. The above thread also mentions concerns about using ESLint to "auto fix" issues, in particular auto fixing some linting issues may be sub-optimal. Prettier vs. ESLint: A ComparisonBased on the above Reddit thread:
In summary: Prettier is excellent for enforcing a consistent code style quickly and easily, while ESLint offers more flexibility and control for linting and style guidelines. Many developers use both tools together to achieve a balance between consistency and customization. |
What product(s) is this story for?
Sage Monorepo
As a user, I want
No response
Description
No response
Acceptance criteria
No response
Tasks
nx format:check
takes after identifying files that must be ignored by PrettierAnything else?
No response
Have you linked this story to a GitHub Project?
The text was updated successfully, but these errors were encountered: