Angular-cli: CLI ignores .editorconfig settings

Created on 10 May 2018  路  5Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 6.0.0
Node: 9.5.0
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.6.0
@angular-devkit/build-angular      0.6.0
@angular-devkit/build-ng-packagr   0.6.0
@angular-devkit/build-optimizer    0.6.0
@angular-devkit/core               0.6.0
@angular-devkit/schematics         0.6.0
@angular/cdk                       6.0.1
@angular/material                  6.0.1
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.0.0
@schematics/angular                0.6.0
@schematics/update                 0.6.0
ng-packagr                         3.0.0-rc.3
rxjs                               6.1.0
typescript                         2.7.2
webpack                            4.6.0

Repro steps

  • $ ng new ng6-test
  • $ cd ng6-test
  • Open .editorconfig and change indent_size = 2 to indent_size = 4, and save.
  • Open angular.json in VSCode and run 'Format Document', and save.
  • $ ng generate library fnord
  • Open ./ng6-test/projects/fnord/src/lib/fnord.component.ts.

Observed behavior

  • angular.json is restored default indent size
  • fnord.component.ts is generated with indent_size = 2 as well

Both files ignore .editorconfig setting.

Desired behavior

  • Generated files should honor .editorconfig settings.
  • Files should not be restored to default indent_size after setting is changed to a different value.

Mention any other details that might be useful (optional)

schematicangular help wanted 3 (nice to have) triage #1 feature

Most helpful comment

Even if there is no .editorconfig Angular CLI should respect the existing indent it finds in the package.json

Yes, this is minor but still annoying. Npm does respect the codestyle therefore I would expect that tools who change it follow the same.

All 5 comments

The file is provided purely for IDE usage and as a convenience thereof. The CLI does not otherwise use it. Post-generation formatting is currently at the discretion of the developer.

Post-generation formatting is currently at the discretion of the developer.

I understand that, even though I think that generating files with respect to .editorconfig would be a nice-to-have feature.

However, post-generation formatting isn't respected in the repro I described. angular.json gets reset to the CLI's internal generation default on ng new library ..., even if post-generation formatting has previously been applied.

Even if there is no .editorconfig Angular CLI should respect the existing indent it finds in the package.json

Yes, this is minor but still annoying. Npm does respect the codestyle therefore I would expect that tools who change it follow the same.

Editorconfig was created to unify settings for all editors so that files will be uniformly formatted with proper line endings, identation, etc. And it's widely adopted.

Since angular-cli creates/modifies files, it'd be great if it would also respect the setting.

Still waiting for this to happen 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sysmat picture sysmat  路  3Comments

donaldallen picture donaldallen  路  3Comments

rwillmer picture rwillmer  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments