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

Problems with alphabetize order rules in Angular 11x #2896

Open
thiagosauddev opened this issue Oct 11, 2023 · 3 comments
Open

Problems with alphabetize order rules in Angular 11x #2896

thiagosauddev opened this issue Oct 11, 2023 · 3 comments

Comments

@thiagosauddev
Copy link

My team and I are having a strange problem with the paths, for me the import must follow one order and for the rest of the team another, and it is only for me that the order is different.

This is my problem:

import { TableOrderComponent } from "src/app/shared/tables/table-order/table-order.cmponent";

import { TableOrderDetailsComponent } from "src/app/shared/tables/table-order-details/table-order-details.cmponent";

It asks me to change the order, passing TableOrderDetails above TableOrder, but my colleagues say the "correct" order is the one in the code above.

TSCONFIG:

{
 "compilerOptions": {
  "target": "es2019",
  "module": "es2020",
  "strict" false,
  "esModuleInterop": true,
  "skipLibCheck": true,
  "forceConsistentCasingInFileNames": true,
  "declaration": false,
  "sourceMap": true,
  "outDir": "./dist/out-tsc",
  "baseUrl": "./"
  "moduleResolution": "node",
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "importHelpers": true,
  "noImplicitAny": false,
  "typeRoots": ["node_modules/@types"],
  "lib": ["es2019", "dom"]
 },
  "angularCompileOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "fullTemplateTypeCheck": false,
    "strictInjectionParameters": false
  }
}

ESLINT:

{
 root: true,
 overrides: [
  files: ["src/**/*.ts"],
  parseOptions: {
   project: ["tsconfig.json", "e2e/tsconfig.json"],
   tsconfigRootDir: __dirname,
   sourceType: "module",
   createDefaultProgram: true 
 },
 extends: [
  "plugin:@angular-eslint/recommended",
  "plugin:@angular-eslint/template/process-inline-templates",
  "airbnb-base",
  "airbnb-typescript/base",
  "eslint:recommended",
  "plugin:@typescript-eslint/eslint-recommended",
  "plugin:prettier/recommended"
 ],
 plugins: ["@typescript-eslint", "prettier", "ununsed-imports", "simple-import-sort"],
 rules: {
  ...,
  "import/order": [
    "error",
    {
     "newlins-between": "never",
     alphabetize: {
      caseInsensitive: true,
      order: "asc" 
    },
    groups: [
     "internal",
     "unknown",
     "external",
     "builtin",
     ["parent", "sibling", "index"]
    ],
    pathGroupsExcludedImportTypes: ["builtin", "type", "object"]
   }
  ]
 }
]
}

LIBS:

@angular/common: ~11.2.14
@angular/compiler: ~11.2.14
@angular/core: ~11.2.14
@angular-devkit/build-angular: ~0.1102.13
@angular-eslint/builder: 4.3.1
@angular-eslint/eslint-plugin: 4.3.1
@angular-eslint/eslint-plugin-template: 4.3.1
@angular-eslint/schematics: 4.3.1
@angular-eslint/template-parser: 4.3.1
@angular-eslint/cli: ~11.2.14
@angular-eslint/compiler-cli: ~11.2.14
eslint: ^7.6.0
eslint-plugin-angular: ^4.1.0
eslint-plugin-import: ^2.25.2
eslint-plugin-simple-import-sort: ^10.0.0
eslint-plugin-unused-imports: ^3.0.0
ts-node: ~8.3.0
typescript: ~4.1.5
@thiagosauddev thiagosauddev changed the title Problems with alphabetize rules in Angular 11x Problems with alphabetize order rules in Angular 11x Oct 11, 2023
@thiagosauddev thiagosauddev changed the title Problems with alphabetize order rules in Angular 11x Problems with alphabetize order rules in Angular 11x Oct 11, 2023
@ljharb
Copy link
Member

ljharb commented Oct 11, 2023

I believe this may be addressed by #2885.

@thiagosauddev
Copy link
Author

thiagosauddev commented Oct 13, 2023

Acredito que isso pode ser resolvido por #2885 .

I didn't understand very well, what would be the solution in this mentioned topic?

Would updating to version 2.26.x solve the problem? Or would I also have to change the alias paths from "src/..." to "../" and or "./"?

If it's the second case of paths, it doesn't make much sense, since using @alias is good practice.

@ljharb
Copy link
Member

ljharb commented Dec 7, 2023

@thiagosauddev the solution would be, waiting for that PR to land and be released.

While using aliases is a neutral practice, using @alias specifically is a bad practice, since a leading @ means "an npm scope". You should pick a character that doesn't already mean something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants