Enforces importing index file with .
instead of ./
, ./index
or ./index.js
.
This rule is fixable.
const m = require('./');
const m = require('../');
const m = require('./index');
const m = require('./index.js');
const m = require('./foo/index.js');
const m = require('@foo/bar/index');
import m from './';
import m from './index';
const m = require('.');
const m = require('..');
const m = require('./foo');
const m = require('@foo/bar');
import m from '.';
Type: boolean
Default: false
Don't check import
statements.
Can be useful if you're using native import
in Node.js where the filename and extension is required.
// eslint unicorn/import-index: ["error", {"ignoreImports": true}]
import m from './index'; // Passes
// eslint unicorn/import-index: ["error", {"ignoreImports": false}]
import m from './index'; // Fails