Skip to content

Latest commit

Β 

History

History
53 lines (37 loc) Β· 1.28 KB

File metadata and controls

53 lines (37 loc) Β· 1.28 KB

prefer-identifier-import-export-specifiers

πŸ“ Prefer identifiers over string literals in import and export specifiers.

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

Prefer identifier syntax over string-literal syntax in import and export specifiers and import attribute keys when the string is a valid identifier name.

This rule does not require all specifiers to use the same style. Use string literals when the imported or exported name cannot be written as an identifier.

Examples

// ❌
import {'foo' as foo} from 'foo';

// βœ…
import {foo as foo} from 'foo';
// ❌
export {foo as 'bar'};

// βœ…
export {foo as bar};
// ❌
export {'foo' as bar} from 'foo';

// βœ…
export {foo as bar} from 'foo';
// ❌
import foo from 'foo' with {'type': 'json'};

// βœ…
import foo from 'foo' with {type: 'json'};
// βœ…
import {'a string' as aString} from 'foo';