Skip to content

Commit

Permalink
feat(eslint-config-typescript): replace eslint-plugin-import with esl…
Browse files Browse the repository at this point in the history
…int-perfectionist

- Removed eslint-plugin-import from the project
- Added eslint-plugin-perfectionist for better import order management
- Updated ESLint configuration to use eslint-perfectionist rules

BREAKING CHANGE: Projects need to update their dependencies:
1. Remove `eslint-plugin-import` from the dependencies.
2. Add `eslint-plugin-perfectionist` to the dependencies.
3. Update your ESLint configuration in case 'import/order' rules where applied.
    See https://perfectionist.dev/rules/sort-imports for new possible options.
  • Loading branch information
mistrykaran91 authored and kfenner committed Jan 22, 2025
1 parent 6b6d7c9 commit fde5d68
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 1,576 deletions.
21 changes: 11 additions & 10 deletions eslint-config-angular/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import eslintJs from '@eslint/js';
import typescriptEslint from 'typescript-eslint';
import angularEslint from 'angular-eslint';
import importPlugin from 'eslint-plugin-import';
import jsdocPlugin from 'eslint-plugin-jsdoc';
import perfectionist from 'eslint-plugin-perfectionist';
import preferArrowPlugin from 'eslint-plugin-prefer-arrow';

// Keep in sync with eslint-config-typescript (except Angular stuff).
Expand All @@ -18,9 +18,9 @@ export const configBase = typescriptEslint.config({
...angularEslint.configs.tsRecommended
],
plugins: {
'import': importPlugin,
'jsdoc': jsdocPlugin,
'prefer-arrow': preferArrowPlugin
'prefer-arrow': preferArrowPlugin,
perfectionist
},
languageOptions: {
parserOptions: {
Expand Down Expand Up @@ -109,17 +109,18 @@ export const configRecommended = typescriptEslint.config({
'no-implied-eval': ['off'],
'no-loop-func': ['off'],
'no-useless-constructor': ['off'],
'import/order': [
'perfectionist/sort-imports': [
'error',
{
groups: ['builtin', 'external'],
alphabetize: {
order: 'asc'
},
'newlines-between': 'always'
type: 'alphabetical',
order: 'asc',
newlinesBetween: 'always',
groups: [
['builtin', 'external'],
['parent', 'sibling', 'index']
]
}
],

'@angular-eslint/component-max-inline-declarations': ['off'],
'@angular-eslint/prefer-on-push-component-change-detection': ['off'],
'@angular-eslint/use-component-selector': ['off'],
Expand Down
2 changes: 1 addition & 1 deletion eslint-config-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@eslint/js": "^9.9.1",
"angular-eslint": "^18.1.0 || ^19.0.0",
"eslint": "^9.9.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-perfectionist": "^4.6.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"typescript-eslint": "^8.0.0"
}
Expand Down
20 changes: 11 additions & 9 deletions eslint-config-typescript/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*/
import eslintJs from '@eslint/js';
import typescriptEslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import jsdocPlugin from 'eslint-plugin-jsdoc';
import perfectionist from 'eslint-plugin-perfectionist';
import preferArrowPlugin from 'eslint-plugin-prefer-arrow';

// Keep in sync with eslint-config-angular (except Angular stuff).

export const configBase = typescriptEslint.config({
extends: [eslintJs.configs.recommended, ...typescriptEslint.configs.recommended],
plugins: {
'import': importPlugin,
'jsdoc': jsdocPlugin,
'prefer-arrow': preferArrowPlugin
'prefer-arrow': preferArrowPlugin,
perfectionist
},
languageOptions: {
parserOptions: {
Expand Down Expand Up @@ -99,14 +99,16 @@ export const configRecommended = typescriptEslint.config({
}
},
rules: {
'import/order': [
'perfectionist/sort-imports': [
'error',
{
groups: ['builtin', 'external'],
alphabetize: {
order: 'asc'
},
'newlines-between': 'always'
type: 'alphabetical',
order: 'asc',
newlinesBetween: 'always',
groups: [
['builtin', 'external'],
['parent', 'sibling', 'index']
]
}
],
'@typescript-eslint/naming-convention': [
Expand Down
2 changes: 1 addition & 1 deletion eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"peerDependencies": {
"@eslint/js": "^9.9.1",
"eslint": "^9.9.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-perfectionist": "^4.6.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"typescript-eslint": "^8.0.0"
}
Expand Down
3 changes: 1 addition & 2 deletions eslint-plugin-defaultvalue/lib/rules/ConfigCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import * as path from 'path';

import { TSDocConfigFile } from '@microsoft/tsdoc-config';
import * as path from 'path';

interface ICachedConfig {
loadTimeMs: number;
Expand Down
Loading

0 comments on commit fde5d68

Please sign in to comment.