Closed
Description
Reproduction:
https://github.com/kylemh/demo-import-x-issue
pnpm dlx create-next-app@latest --use-pnpm
touch .nvmrc
- add 22 to
.nvmrc
- nvm use
- pnpm add -D typescript-eslint eslint-plugin-import-x @typescript-eslint/parser
- paste below config into
eslint.config.mjs
- Create dummy files and purposefully set bad order (source code at bottom of this post)
Config
eslint.config.mjs
:
import tseslint from 'typescript-eslint';
import eslintPluginImportX from 'eslint-plugin-import-x';
import tsParser from '@typescript-eslint/parser';
/**
* @type {import("eslint").Linter.Config['languageOptions']}
* @see https://typescript-eslint.io/getting-started/typed-linting
*/
const languageOptions = {
parser: tsParser,
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
ecmaVersion: 'latest',
sourceType: 'module',
};
/**
* @type {import("eslint").Linter.Config}
*/
const allTheRules = {
files: ['./src/**/*.{ts,tsx}'],
rules: {
// @typescript-eslint plugin rules
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['variable', 'parameter', 'parameterProperty', 'typeProperty', 'classProperty'],
types: ['boolean'],
format: ['PascalCase', 'UPPER_CASE'],
prefix: [
'is',
'was',
'should',
'has',
'can',
'did',
'will',
'IS_',
'WAS_',
'SHOULD_',
'HAS_',
'CAN_',
'DID_',
'WILL_',
],
},
],
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-unused-vars': 'error',
// import plugin rules
'import-x/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'unknown',
'type',
],
'newlines-between': 'always',
},
],
'import-x/no-named-as-default': 'off',
},
};
export default tseslint.config(
{ ignores: ['./eslint.config.mjs'] },
tseslint.configs.recommendedTypeChecked,
{ languageOptions }, // will be used for all configs below
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
allTheRules,
);
Relevant Source Code
No errors in the below within src/app/layout.tsx
import './globals.css';
import './';
import { Geist, Geist_Mono } from 'next/font/google';
import { log } from '@/utils/log';
import type { Metadata } from 'next';
Metadata
Metadata
Assignees
Labels
No labels