-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix]
no-unused-prop-types
: improve component declared props detection
Fixes #2752.
- Loading branch information
Showing
5 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Check if the first letter of a string is capitalized. | ||
* @param {String} word String to check | ||
* @returns {Boolean} True if first letter is capitalized. | ||
*/ | ||
function isFirstLetterCapitalized(word) { | ||
if (!word) { | ||
return false; | ||
} | ||
const firstLetter = word.charAt(0); | ||
return firstLetter.toUpperCase() === firstLetter; | ||
} | ||
|
||
module.exports = isFirstLetterCapitalized; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
const isFirstLetterCapitalized = require('../../lib/util/isFirstLetterCapitalized'); | ||
|
||
describe('isFirstLetterCapitalized', () => { | ||
it('should return false for invalid input', () => { | ||
assert.equal(isFirstLetterCapitalized(), false); | ||
assert.equal(isFirstLetterCapitalized(null), false); | ||
assert.equal(isFirstLetterCapitalized(''), false); | ||
}); | ||
|
||
it('should return false for uncapitalized string', () => { | ||
assert.equal(isFirstLetterCapitalized('isCapitalized'), false); | ||
assert.equal(isFirstLetterCapitalized('lowercase'), false); | ||
}); | ||
|
||
it('should return true for capitalized string', () => { | ||
assert.equal(isFirstLetterCapitalized('IsCapitalized'), true); | ||
assert.equal(isFirstLetterCapitalized('UPPERCASE'), true); | ||
}); | ||
}); |