@@ -40,96 +40,161 @@ ruleTester.run("no-shadow-restricted-names", rule, {
4040{
4141code :"let undefined" ,
4242languageOptions :{ ecmaVersion :2015 }
43+ } ,
44+ {
45+ code :"import { undefined as undef } from 'foo';" ,
46+ languageOptions :{
47+ sourceType :"module" ,
48+ ecmaVersion :2015
49+ }
4350}
4451] ,
4552invalid :[
4653{
4754code :"function NaN(NaN) { var NaN; !function NaN(NaN) { try {} catch(NaN) {} }; }" ,
4855errors :[
49- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" } ,
50- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" } ,
51- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" } ,
52- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" } ,
53- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" } ,
54- { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" }
56+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 10 } ,
57+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 14 } ,
58+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 25 } ,
59+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 40 } ,
60+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 44 } ,
61+ { messageId :"shadowingRestrictedName" , data :{ name :"NaN" } , type :"Identifier" , column : 64 }
5562]
5663} ,
5764{
5865code :"function undefined(undefined) { !function undefined(undefined) { try {} catch(undefined) {} }; }" ,
5966errors :[
60- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
61- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
62- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
63- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
64- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" }
67+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 10 } ,
68+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 20 } ,
69+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 43 } ,
70+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 53 } ,
71+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 79 }
6572]
6673} ,
6774{
6875code :"function Infinity(Infinity) { var Infinity; !function Infinity(Infinity) { try {} catch(Infinity) {} }; }" ,
6976errors :[
70- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" } ,
71- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" } ,
72- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" } ,
73- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" } ,
74- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" } ,
75- { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" }
77+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 10 } ,
78+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 19 } ,
79+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 35 } ,
80+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 55 } ,
81+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 64 } ,
82+ { messageId :"shadowingRestrictedName" , data :{ name :"Infinity" } , type :"Identifier" , column : 89 }
7683]
7784} ,
7885{
7986code :"function arguments(arguments) { var arguments; !function arguments(arguments) { try {} catch(arguments) {} }; }" ,
8087errors :[
81- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" } ,
82- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" } ,
83- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" } ,
84- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" } ,
85- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" } ,
86- { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" }
88+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 10 } ,
89+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 20 } ,
90+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 37 } ,
91+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 58 } ,
92+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 68 } ,
93+ { messageId :"shadowingRestrictedName" , data :{ name :"arguments" } , type :"Identifier" , column : 94 }
8794]
8895} ,
8996{
9097code :"function eval(eval) { var eval; !function eval(eval) { try {} catch(eval) {} }; }" ,
9198errors :[
92- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
93- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
94- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
95- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
96- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
97- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" }
99+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 10 } ,
100+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 15 } ,
101+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 27 } ,
102+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 43 } ,
103+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 48 } ,
104+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 69 }
98105]
99106} ,
100107{
101108code :"var eval = (eval) => { var eval; !function eval(eval) { try {} catch(eval) {} }; }" ,
102109languageOptions :{ ecmaVersion :6 } ,
103110errors :[
104- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
105- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
106- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
107- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
108- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" } ,
109- { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" }
111+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 5 } ,
112+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 13 } ,
113+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 28 } ,
114+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 44 } ,
115+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 49 } ,
116+ { messageId :"shadowingRestrictedName" , data :{ name :"eval" } , type :"Identifier" , column : 70 }
110117]
111118} ,
112119{
113120code :"var [undefined] = [1]" ,
114121languageOptions :{ ecmaVersion :6 } ,
115122errors :[
116- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" }
123+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 6 }
117124]
118125} ,
119126{
120127code :"var {undefined} = obj; var {a: undefined} = obj; var {a: {b: {undefined}}} = obj; var {a, ...undefined} = obj;" ,
121128languageOptions :{ ecmaVersion :9 } ,
122129errors :[
123- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
124- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
125- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" } ,
126- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" }
130+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 6 } ,
131+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 32 } ,
132+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 63 } ,
133+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column : 94 }
127134]
128135} ,
129136{
130137code :"var undefined; undefined = 5;" ,
131138errors :[
132- { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" }
139+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :5 }
140+ ]
141+ } ,
142+ {
143+ code :"class undefined {}" ,
144+ languageOptions :{
145+ ecmaVersion :2015
146+ } ,
147+ errors :[
148+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :7 }
149+ ]
150+ } ,
151+ {
152+ code :"(class undefined {})" ,
153+ languageOptions :{
154+ ecmaVersion :2015
155+ } ,
156+ errors :[
157+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :8 }
158+ ]
159+ } ,
160+ {
161+ code :"import undefined from 'foo';" ,
162+ languageOptions :{
163+ ecmaVersion :2015 ,
164+ sourceType :"module"
165+ } ,
166+ errors :[
167+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :8 }
168+ ]
169+ } ,
170+ {
171+ code :"import { undefined } from 'foo';" ,
172+ languageOptions :{
173+ ecmaVersion :2015 ,
174+ sourceType :"module"
175+ } ,
176+ errors :[
177+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :10 }
178+ ]
179+ } ,
180+ {
181+ code :"import { baz as undefined } from 'foo';" ,
182+ languageOptions :{
183+ ecmaVersion :2015 ,
184+ sourceType :"module"
185+ } ,
186+ errors :[
187+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :17 }
188+ ]
189+ } ,
190+ {
191+ code :"import * as undefined from 'foo';" ,
192+ languageOptions :{
193+ ecmaVersion :2015 ,
194+ sourceType :"module"
195+ } ,
196+ errors :[
197+ { messageId :"shadowingRestrictedName" , data :{ name :"undefined" } , type :"Identifier" , column :13 }
133198]
134199}
135200]