Skip to content

VBC-104: inconsistent-import

warning

Category: clean-code
Analysis: Regex (whole file)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: clean-code

What it reports

Mixing 'require' and 'import' in the same file at line {line}.

Flagged

js
import fs from 'fs';
const path = require('path');

Not flagged

js
import fs from 'fs';
import path from 'path';

Pattern

regex
^[ \t]*import\s[\s\S]{0,4000}?^[ \t]*(?:const|let|var)\s[^\n]*=\s*require\(|^[ \t]*(?:const|let|var)\s[^\n]*=\s*require\([\s\S]{0,4000}?^[ \t]*import\s

Released under the MIT License.