Closed
Description
The newline-after-import
rule does not appear to work when the first content encountered after imports is JSDoc. Take the following eslint.config.js
as an example:
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginImport from 'eslint-plugin-import';
import globals from 'globals';
import ts from 'typescript-eslint';
/**
* @type {import('eslint').Linter.Config[]}
*/
export default ts.config([
eslintConfigPrettier,
js.configs.recommended,
...ts.configs.strict,
...ts.configs.stylistic,
{
plugins: {
import: eslintPluginImport,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
},
rules: {
'import/newline-after-import': ['error', { count: 1 }],
},
},
]);
ESLint doesn't indicate the expected error after the import statements, but removing the JSDoc will result in the correct behavior:
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginImport from 'eslint-plugin-import';
import globals from 'globals';
import ts from 'typescript-eslint'; // Expected 1 empty line after import statement not followed by another import.eslint[import/newline-after-import](https://github.com/import-js/eslint-plugin-import/blob/v2.31.0/docs/rules/newline-after-import.md)
export default ts.config([
eslintConfigPrettier,
js.configs.recommended,
...ts.configs.strict,
...ts.configs.stylistic,
{
plugins: {
import: eslintPluginImport,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
},
rules: {
'import/newline-after-import': ['error', { count: 1 }],
},
},
]);
Metadata
Metadata
Assignees
Labels
No labels