Skip to content

Commit 8754dcd

Browse files
committed
- Expand types checked
1 parent 4640a35 commit 8754dcd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.README/rules/check-types.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Reports invalid types.
55
Ensures that case of native types is the same as in this list:
66

77
```
8+
undefined
9+
null
810
boolean
911
number
1012
string
@@ -16,9 +18,9 @@ RegExp
1618

1719
#### Why not capital case everything?
1820

19-
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
21+
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
2022

21-
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
23+
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
2224

2325
So in a sense, there two types of strings in Javascript; `{string}` literals, also called primitives and `{String}` Objects. We use the primitives because it's easier to write and uses less memory. `{String}` and `{string}` are technically both valid, but they are not the same.
2426

src/rules/checkTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const targetTagAliases = [
3131
targetTags = targetTags.concat(targetTagAliases);
3232

3333
const strictNativeTypes = [
34+
'undefined',
35+
'null',
3436
'boolean',
3537
'number',
3638
'string',

0 commit comments

Comments
 (0)