From b26592ee930c51f60f1c9da26868d83aa4191b70 Mon Sep 17 00:00:00 2001 From: Kevin Lau Date: Thu, 18 Jul 2019 22:33:43 -0700 Subject: [PATCH] Update `import-name` README.md Add documentation and examples of all the `import-name` options. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c0909eb8..4570010b1 100644 --- a/README.md +++ b/README.md @@ -184,11 +184,16 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic The name of the imported module must match the name of the thing being imported. For special characters (-, ., _) remove them and make the following character uppercase. - For example, it is valid to name imported modules the same as the module name: import Service = require('x/y/z/Service') and import Service from 'x/y/z/Service'. + For example, it is valid to name imported modules the same as the module name: import Service = require('./x/y/z/Service') and import Service from './x/y/z/Service'. But it is invalid to change the name being imported, such as: import MyCoolService = require('x/y/z/Service') and import MyCoolService from 'x/y/z/Service'. When containing special characters such as import $$ from 'my-awesome_library'; the corresponding configuration would look like 'import-name': [true, { 'myAwesomeLibrary': '$$' }]. Since version 2.0.9 it is possible to configure this rule with a list of exceptions. - For example, to allow underscore to be imported as _, add this configuration: 'import-name': [ true, { 'underscore': '_' }] + The default is to ignore this rule for external modules ignoreExternalModule: true and to use camelCase case: 'camelCase'. + To not ignore this rule for external modules, add this configuration: 'import-name': [true, null, null, { ignoreExternalModule: false }]. + To allow underscore to be imported as _, add this configuration: 'import-name': [true, { 'underscore': '_' }, null, { ignoreExternalModule: false }]. + To ignore this rule for react and express, add this configuration: 'import-name': [true, null, ['react', 'express'], { ignoreExternalModule: false }]. + To use PascalCase: 'import-name': [true, null, null, { case: 'PascalCase' }]. + To use camelCase or PascalCase: 'import-name': [true, null, null, { case: 'any-case' }]. 2.0.5