Comments (6)
Fixed in f35deef.
Will be released today.
from eslint-plugin-perfectionist.
I just tested v2.1.0
, it seems to work for files directly in the root but not for paths with folders:
// it works
import fs from "node:fs/promises";
import { type SDK } from "#config.js";
// it doesn't work
import { type SDK } from "#config/index.js";
import fs from "node:fs/promises";
My config:
"perfectionist/sort-imports": ["error", {
...perfectionistPlugin.configs["recommended-natural"].rules["perfectionist/sort-imports"][1],
"newlines-between": "never",
"internal-pattern": ["#**"],
}],
Edit
This internal-pattern
syntax seems to do the trick! 💯
"internal-pattern": ["#*", "#*/**"],
from eslint-plugin-perfectionist.
Could you show me your current ESLint config?
from eslint-plugin-perfectionist.
@azat-io sure, here it is:
import typescriptPlugin from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
import importPlugin from 'eslint-plugin-import'
import nodeImportPlugin from 'eslint-plugin-node-import'
import perfectionistPlugin from 'eslint-plugin-perfectionist'
import unusedImportsPlugin from "eslint-plugin-unused-imports"
import globals from "globals";
export default [
{
files: [`**/*.@(js|jsx|ts|tsx)`],
ignores: [`.dts/**`],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parser: typescriptParser,
parserOptions: {
project: `./tsconfig.json`,
},
},
plugins: {
'@typescript-eslint': typescriptPlugin,
'import': importPlugin,
'node-import': nodeImportPlugin,
'perfectionist': perfectionistPlugin,
'unused-imports': unusedImportsPlugin,
},
rules: {
...typescriptPlugin.configs['eslint-recommended'].rules,
...typescriptPlugin.configs['strict-type-checked'].rules,
...typescriptPlugin.configs['stylistic-type-checked'].rules,
...importPlugin.configs.recommended.rules,
...perfectionistPlugin.configs['recommended-natural'].rules,
"@typescript-eslint/array-type": ["error", { default: "generic" }],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": "off",
"import/consistent-type-specifier-style": ["error", "prefer-inline"],
"import/no-duplicates": ["error", { "prefer-inline": true }],
"import/no-unresolved": "off",
"node-import/prefer-node-protocol": "error",
"perfectionist/sort-imports": ["error", { "internal-pattern": ["#*", "#**"] }],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": ["error", { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }],
},
},
]
from eslint-plugin-perfectionist.
It looks like you forgot to configure the import groups.
'perfectionist/sort-imports': [
'error',
{
groups: [
'type',
['builtin', 'external'],
'internal-type',
'internal',
['parent-type', 'sibling-type', 'index-type'],
['parent', 'sibling', 'index'],
'object',
'unknown',
],
'internal-pattern': ['#/**'],
},
],
from eslint-plugin-perfectionist.
Yes I just realized that I override the whole sort-imports
rule. 😅
Unfortunately it's still not working:
"perfectionist/sort-imports": ["error", {
...perfectionistPlugin.configs["recommended-natural"].rules["perfectionist/sort-imports"][1],
"newlines-between": "never",
"internal-pattern": ["#*", "#**"],
}],
I think the issue is that minimatch
is not able to apply the patterns #*
or #**
. With imports
aliases, you can't have #/
(notice the slash here).
from eslint-plugin-perfectionist.
Related Issues (20)
- Feature: Idiomatic Order
- Bug: (Failed to compile. [eslint] Cannot read properties of undefined (reading 'getTokensBetween') Occurred while linting /home/itpmbot-dev/builds/K/0/itpm-chat-bot/bot-frontend/src/index.jsx:2 Rule: "perfectionist/sort-imports") HOT 7
- Feature: additional configuration with `ignore-case: true` HOT 1
- Bug: Allow for sorting on certain groups and not others HOT 1
- Bug: sort-imports generates wrong results HOT 3
- Feature: Add zod `z.enum` support to `sort-enums`
- Feature: (option for line-length to sort imports by their last line, instead of their total characters)
- Feature: Add a sort-intersection-types rule? HOT 1
- Feature: add `partition-by-new-line` option to rules HOT 2
- Feature: add `side-effect-style` HOT 1
- Bug: sort-imports auto-fixing HOT 1
- Release: v3.0.0 HOT 5
- Feature: Exclude objects with Linaria classNames when `styled-components: false` is enabled? HOT 3
- sort-classes to support decorated properties HOT 1
- Bug: Error while loading rule 'perfectionist/sort-svelte-attributes': The "path" argument must be of type string. HOT 10
- Bug: (The plugin does not respect inline type qualifiers) HOT 4
- Feature: Add checking ignore patterns for JSX properties name in sort-object HOT 1
- If something should be sorted, move all above comments with that before a blank line or a non-comment entity is found HOT 1
- Allow custom sorting for sort-array-includes
- use auto fix without any warnings or errors HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-perfectionist.