Skip to content

Commit 30aca14

Browse files
Eric LiprandiJosh Goldberg
Eric Liprandi
authored and
Josh Goldberg
committed
add clarification to import-name rule (microsoft#590)
show example for more complex package name, including snake case.
1 parent 9180e32 commit 30aca14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Rule Name | Description | Since
6767
`chai-vague-errors` | Avoid Chai assertions that result in vague errors. For example, asserting `expect(something).to.be.true` will result in the failure message "Expected true received false". This is a vague error message that does not reveal the underlying problem. It is especially vague in TypeScript because stack trace line numbers often do not match the source code. A better pattern to follow is the xUnit Patterns [Assertion Message](http://xunitpatterns.com/Assertion%20Message.html) pattern. The previous code sample could be better written as `expect(something).to.equal(true, 'expected something to have occurred');`| 1.0
6868
`export-name` | The name of the exported module must match the filename of the source file. This is case-insensitive by default but ignores file extension. It can be configured to be case-insensitive or to allow names matching a regex. For example, to allow names that differ only in case and an exported name like myChartOptions, then configure the rule like this: `"export-name": [true, { "ignore-case": true, "allow": ["myChartOptions"] }]`. You can also just give a list of allowed names, like `"export-name": [true, "myChartOptions"]`| 0.0.3
6969
`function-name` | Applies a naming convention to function names and method names. You can configure the naming convention by passing parameters. Please note, the private-method-regex does take precedence over the static-method-regex, so a private static method must match the private-method-regex. The default values are: <br> [ true, { <br> "method-regex": "^[a-z][\\w\\d]+$",<br> "private-method-regex": "^[a-z][\\w\\d]+$",<br> "protected-method-regex": "^[a-z][\\w\\d]+$",<br> "static-method-regex": "^[A-Z_\\d]+$",<br> "function-regex": "^[a-z][\\w\\d]+$"<br> } ]<br/>This rule has some overlap with the [tslint variable-name rule](https://palantir.github.io/tslint/rules/variable-name/); however, the rule here is more configurable. | 2.0.7, 2.0.14
70-
`import-name` | The name of the imported module must match the name of the thing being imported. 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'`. 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': '_' }]`| 2.0.5
70+
`import-name` | The name of the imported module must match the name of the thing being imported. 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'`. 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': '_' }]`. Note that the name of the package is the expected camelCase name of the package. For example, to allow `request-promise-native` to be imported as `request`, add this configuration: `'import-name': [true, { 'requestPromiseNative': 'request'}]`| 2.0.5
7171
`informative-docs` | Enforces that comments do more than just reiterate names of objects. Either be informative with comments or don't include a comment. You can override the default list of "useless" words ignored by the comment checker like `"informative-docs": [true, { "useless-words": ["a", "an", "the", "text" ] } ]`. You can indicate words as synonyms (aliases) of each other like `"informative-docs": [true, { "aliases": { text: ["emoji", "smiley"] } ]`.
7272
`insecure-random` | Do not use insecure sources for random bytes. Use a secure random number generator instead. Bans all uses of Math.random and crypto.pseudoRandomBytes. Better alternatives are crypto.randomBytes and window.crypto.getRandomValues.<br/>References:<br/>* [CWE 330](https://cwe.mitre.org/data/definitions/330.html)<br/>* [MDN Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)<br/>* [Node.js crypto.randomBytes()](https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback)<br/>* [window.crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues)<br/> | 2.0.11
7373
`jquery-deferred-must-complete` | When a JQuery Deferred instance is created, then either reject() or resolve() must be called on it within all code branches in the scope. For more examples see the [feature request](https://github.com/Microsoft/tslint-microsoft-contrib/issues/26). | 1.0

0 commit comments

Comments
 (0)