import-js/eslint-plugin-import

New rules regarding namespaces used as values

Aperta

#532 aperta il 29 ago 2016

 (8 commenti) (1 reazione) (0 assegnatari)JavaScript (1549 fork)batch import
acceptedhelp wantedrule proposalsemver-minor

Metriche repository

Star
 (5940 stelle)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

The following patterns are considered not warnings:

import * as foo from "./foo";

foo.bar();
const baz = foo.baz;
const {property} = foo;

The following patterns are considered warnings:

import * as foo from "./foo";

foo();
const [value] = foo;
func(foo);
func(...foo);
const alias = foo;
const {child} = foo; // foo.child is an exported namespace

Basically, warn if a namespace is used in a way that cannot be validated (aliased, called, destructured as array, passed as argument, etc.). There's no overlap with namespace.allowComputed in the above, but that option could be merged into this one, or these merged into another namespace option.

Guida contributor