Skip to content

Commit

Permalink
Allow consecutive uppercase letters in jsx-pascal-case
Browse files Browse the repository at this point in the history
I've run into a couple of cases where I have consecutive capital letters
in React components (e.g. <CSSTransitionGroup>), and jsx-pascal-case is
complaining about them. This commit fixes this problem by allowing
consecutive uppercase letters.

Fixes #328
  • Loading branch information
lencioni committed Nov 24, 2015
1 parent 2b3c8c0 commit c5b67d4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
10 changes: 9 additions & 1 deletion docs/rules/jsx-pascal-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The following patterns are considered warnings:
<test_component />
```

```js
<YELLING />
```

The following patterns are not considered warnings:

```js
Expand All @@ -32,6 +36,10 @@ The following patterns are not considered warnings:
</TestComponent>
```

```js
<CSSTransitionGroup />
```

## When Not To Use It

If you are not using JSX.
If you are not using JSX.
2 changes: 1 addition & 1 deletion lib/rules/jsx-pascal-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var variableUtil = require('../util/variable');
// Constants
// ------------------------------------------------------------------------------

var PASCAL_CASE_REGEX = /^[A-Z][a-z]+(?:[A-Z][a-z]+)*$/;
var PASCAL_CASE_REGEX = /^[A-Z]+[a-z]+(?:[A-Z]+[a-z]*)*$/;

// ------------------------------------------------------------------------------
// Rule Definition
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/jsx-pascal-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ ruleTester.run('jsx-pascal-case', rule, {
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var CSSTransitionGroup;',
'<CSSTransitionGroup />'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var BetterThanCSS;',
'<BetterThanCSS />'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var TestComponent;',
Expand Down Expand Up @@ -55,6 +71,15 @@ ruleTester.run('jsx-pascal-case', rule, {
jsx: true
},
errors: [{message: 'Imported JSX component test_component must be in PascalCase'}]
}, {
code: [
'var YELLING;',
'<YELLING />'
].join('\n'),
ecmaFeatures: {
jsx: true
},
errors: [{message: 'Imported JSX component YELLING must be in PascalCase'}]
}, {
code: [
'var testComponent;',
Expand Down

0 comments on commit c5b67d4

Please sign in to comment.