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] Don't create .cdsprettier.json if the project is not SAP CAP project #113

Closed
1 task done
hakimio opened this issue Jan 17, 2025 · 1 comment · Fixed by #114
Closed
1 task done

[BUG] Don't create .cdsprettier.json if the project is not SAP CAP project #113

hakimio opened this issue Jan 17, 2025 · 1 comment · Fixed by #114
Labels
bug Something isn't working

Comments

@hakimio
Copy link

hakimio commented Jan 17, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

It's quite annoying that the plugin now creates .cdsprettier.json everywhere.

  • In case of monorepo project where the SAP CAP project is inside a subfolder, it creates the config in the root directory.
  • In case the opened project is not CAP project, it still creates .cdsprettier.json.

Expected Behavior

Verify that the current project is SAP CAP project by either checking package.json for @sap/cds dependency or checking for .cdsrc.json config existence before creating the .cdsprettier.json config.

Steps To Reproduce

  1. Change the formatting config in any project which is not SAP CAP project.

Versions

plugin 1.4.1
node v22.13.0

OS / Environment

Windows

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

@hakimio hakimio added the bug Something isn't working label Jan 17, 2025
@tim-sh
Copy link
Member

tim-sh commented Jan 17, 2025

@hakimio Thanks for reporting. The fix will introduce a switch enabled by .cds files only. Selecting the file location is currently out of scope.

Situation before fix

New .cdsprettier.json files are created (if missing) under the following circumstances:

  1. On project creation: if the 'Default' settings scheme has previously been modified.1
  2. On project open:
    a. under the same condition, for projects that use an IDE-wide scheme (including 'Default');
    b. for projects using the 'Project' scheme with non-default settings (as designed).
  3. On settings confirmation: for the current project if settings are non-default (as designed).

Workarounds for non-CDS projects

Case 1, 2.a ('Default' scheme)

Switch to 'Project' scheme and reset 'Default' scheme:

  1. Go to each of your current CDS projects and copy your settings from the 'Default' scheme to the 'Project' scheme (use the gear button at the top).
  2. Afterwards, do in any of these projects:
    a. switch back to 'Default' scheme;
    b. use the gear button to restore the defaults;
    c. select 'Project' scheme again.

Case 2.b, 3 (with 'Project' scheme)

None; don't switch CDS code-style settings to 'Project' scheme in non-CDS projects.

Footnotes

  1. by selecting Default in the drop-down box at the top of the dialog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants