Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcf0df5

Browse files
feat: limit namespace import identifier in id-length rule (#18849)
* feat: limit namespace import identifier in id-length rule* test: add tests for valid case in 'id-length' rule* refactor: Sort order, Change variable name to semantic name* Update lib/rules/id-length.jsCo-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>* Update tests/lib/rules/id-length.jsCo-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>* Update tests/lib/rules/id-length.jsCo-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>* test: add test for shows that ImportSpecifiers are allowed even with default 2 and with max option---------Co-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>
1 parent45c18e1 commitbcf0df5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎lib/rules/id-length.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ module.exports = {
117117
returnproperties&&!parent.computed&&parent.key.name===node.name;
118118
},
119119
ImportDefaultSpecifier:true,
120+
ImportNamespaceSpecifier:true,
120121
RestElement:true,
121122
FunctionExpression:true,
122123
ArrowFunctionExpression:true,

‎tests/lib/rules/id-length.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ ruleTester.run("id-length", rule, {
6464
{code:"({ a: obj.x.y.z } = {});",options:[{properties:"never"}],languageOptions:{ecmaVersion:6}},
6565
{code:"import something from 'y';",languageOptions:{ecmaVersion:6,sourceType:"module"}},
6666
{code:"export var num = 0;",languageOptions:{ecmaVersion:6,sourceType:"module"}},
67+
{code:"import * as something from 'y';",languageOptions:{ecmaVersion:6,sourceType:"module"}},
68+
{code:"import { x } from 'y';",languageOptions:{ecmaVersion:6,sourceType:"module"}},
69+
{code:"import { longName } from 'y';",options:[{max:5}],languageOptions:{ecmaVersion:6,sourceType:"module"}},
6770
{code:"({ prop: obj.x.y.something } = {});",languageOptions:{ecmaVersion:6}},
6871
{code:"({ prop: obj.longName } = {});",languageOptions:{ecmaVersion:6}},
6972
{code:"var obj = { a: 1, bc: 2 };",options:[{properties:"never"}]},
@@ -246,6 +249,20 @@ ruleTester.run("id-length", rule, {
246249
{code:"var [i] = arr;",languageOptions:{ecmaVersion:6},errors:[tooShortError]},
247250
{code:"var [,i,a] = arr;",languageOptions:{ecmaVersion:6},errors:[tooShortError,tooShortError]},
248251
{code:"function foo([a]) {}",languageOptions:{ecmaVersion:6},errors:[tooShortError]},
252+
{code:"import x from 'module';",languageOptions:{ecmaVersion:6},errors:[tooShortError]},
253+
{code:"import * as x from 'module';",languageOptions:{ecmaVersion:6},errors:[tooShortError]},
254+
{
255+
code:"import longName from 'module';",
256+
options:[{max:5}],
257+
languageOptions:{ecmaVersion:6},
258+
errors:[tooLongError]
259+
},
260+
{
261+
code:"import * as longName from 'module';",
262+
options:[{max:5}],
263+
languageOptions:{ecmaVersion:6},
264+
errors:[tooLongError]
265+
},
249266
{
250267
code:"var _$xt_$ = Foo(42)",
251268
options:[{min:2,max:4}],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp