Skip to content

Commit ac284a2

Browse files
committed
Revert "BREAKING CHANGE: check-types now expects "object" instead of "Object""
This reverts commit c2e706b.
1 parent 9d993b2 commit ac284a2

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

.README/rules/check-types.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ null
1010
boolean
1111
number
1212
string
13-
object
13+
Object
1414
Array
1515
Date
1616
RegExp
@@ -41,23 +41,18 @@ new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
4141
new String('lard') === 'lard' // false
4242
```
4343

44-
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object.
45-
46-
However, `Object.create(null)` objects are not `instanceof Object`, however, so
47-
in the case of this Object we lower-case to indicate possible support for
48-
these objects.
44+
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object. (`Object.create(null)` objects are not, however.)
4945

5046
Basically, for primitives, we want to define the type as a primitive, because that's what we use in 99.9% of cases. For everything else, we use the type rather than the primitive. Otherwise it would all just be `{object}`.
5147

52-
In short: It's not about consistency, rather about the 99.9% use case. (And some
53-
functions might not even support the objects if they are checking for identity.)
48+
In short: It's not about consistency, rather about the 99.9% use case.
5449

5550
type name | `typeof` | check-types | testcase
5651
--|--|--|--
52+
**Object** | object | **Object** | `({}) instanceof Object` -> `true`
5753
**Array** | object | **Array** | `([]) instanceof Array` -> `true`
5854
**Date** | object | **Date** | `(new Date()) instanceof Date` -> `true`
5955
**RegExp** | object | **RegExp** | `(new RegExp(/.+/)) instanceof RegExp` -> `true`
60-
**Object** | object | **object** | `({}) instanceof Object` -> `true` but `Object.create(null) instanceof Object` -> `false`
6156
Boolean | **boolean** | **boolean** | `(true) instanceof Boolean` -> **`false`**
6257
Number | **number** | **number** | `(41) instanceof Number` -> **`false`**
6358
String | **string** | **string** | `("test") instanceof String` -> **`false`**

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ null
12481248
boolean
12491249
number
12501250
string
1251-
object
1251+
Object
12521252
Array
12531253
Date
12541254
RegExp
@@ -1281,23 +1281,18 @@ new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
12811281
new String('lard') === 'lard' // false
12821282
```
12831283

1284-
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object.
1285-
1286-
However, `Object.create(null)` objects are not `instanceof Object`, however, so
1287-
in the case of this Object we lower-case to indicate possible support for
1288-
these objects.
1284+
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object. (`Object.create(null)` objects are not, however.)
12891285

12901286
Basically, for primitives, we want to define the type as a primitive, because that's what we use in 99.9% of cases. For everything else, we use the type rather than the primitive. Otherwise it would all just be `{object}`.
12911287

1292-
In short: It's not about consistency, rather about the 99.9% use case. (And some
1293-
functions might not even support the objects if they are checking for identity.)
1288+
In short: It's not about consistency, rather about the 99.9% use case.
12941289

12951290
type name | `typeof` | check-types | testcase
12961291
--|--|--|--
1292+
**Object** | object | **Object** | `({}) instanceof Object` -> `true`
12971293
**Array** | object | **Array** | `([]) instanceof Array` -> `true`
12981294
**Date** | object | **Date** | `(new Date()) instanceof Date` -> `true`
12991295
**RegExp** | object | **RegExp** | `(new RegExp(/.+/)) instanceof RegExp` -> `true`
1300-
**Object** | object | **object** | `({}) instanceof Object` -> `true` but `Object.create(null) instanceof Object` -> `false`
13011296
Boolean | **boolean** | **boolean** | `(true) instanceof Boolean` -> **`false`**
13021297
Number | **number** | **number** | `(41) instanceof Number` -> **`false`**
13031298
String | **string** | **string** | `("test") instanceof String` -> **`false`**
@@ -1380,11 +1375,11 @@ function qux(foo) {
13801375
/**
13811376
* @param {abc} foo
13821377
* @param {cde} bar
1383-
* @param {object} baz
1378+
* @param {Object} baz
13841379
*/
13851380
function qux(foo, bar, baz) {
13861381
}
1387-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Cde"},"object":"Object"}}}
1382+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Cde"},"Object":"object"}}}
13881383
// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
13891384

13901385
/**
@@ -1526,12 +1521,12 @@ function quux () {
15261521
// Options: [{"noDefaults":true}]
15271522

15281523
/**
1529-
* @param {Object} foo
1524+
* @param {object} foo
15301525
*/
15311526
function quux (foo) {
15321527

15331528
}
1534-
// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
1529+
// Settings: {"jsdoc":{"preferredTypes":{"Object":"object"}}}
15351530
````
15361531

15371532

src/rules/checkTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const strictNativeTypes = [
99
'number',
1010
'string',
1111
'Array',
12-
'object',
12+
'Object',
1313
'RegExp',
1414
'Date',
1515
'Function'

test/rules/assertions/checkTypes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default {
204204
/**
205205
* @param {abc} foo
206206
* @param {cde} bar
207-
* @param {object} baz
207+
* @param {Object} baz
208208
*/
209209
function qux(foo, bar, baz) {
210210
}
@@ -220,7 +220,7 @@ export default {
220220
},
221221
{
222222
line: 5,
223-
message: 'Invalid JSDoc @param "baz" type "object"; prefer: "Object".'
223+
message: 'Invalid JSDoc @param "baz" type "Object"; prefer: "object".'
224224
}
225225
],
226226
settings: {
@@ -234,7 +234,7 @@ export default {
234234
message: 'More messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{preferredType}}".',
235235
replacement: 'Cde'
236236
},
237-
object: 'Object'
237+
Object: 'object'
238238
}
239239
}
240240
}
@@ -577,7 +577,7 @@ export default {
577577
{
578578
code: `
579579
/**
580-
* @param {Object} foo
580+
* @param {object} foo
581581
*/
582582
function quux (foo) {
583583
@@ -586,7 +586,7 @@ export default {
586586
settings: {
587587
jsdoc: {
588588
preferredTypes: {
589-
object: 'Object'
589+
Object: 'object'
590590
}
591591
}
592592
}

0 commit comments

Comments
 (0)