close

import/namespace

Configuration

rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/namespace': 'error',
    },
  },
]);

Rule Details

Enforces that properties read from namespace imports exist in the imported module.

Examples of incorrect code for this rule:

import * as names from './named-exports';

names.missing;
import * as names from './named-exports';

names['dynamic'];
import * as names from './named-exports';

names.foo = 1;

Examples of correct code for this rule:

import * as names from './named-exports';

names.foo;

Examples of correct code for this rule with { "allowComputed": true }:

{ "import/namespace": ["error", { "allowComputed": true }] }
import * as names from './named-exports';

names[key];

Options

allowComputed

Defaults to false. When set to true, computed namespace member access is allowed, but the computed property name is not validated.

Modules that cannot be resolved, are ignored, or are not ES modules are not reported by this rule.

Original Documentation