Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: airbnb/javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eslint-config-airbnb-v18.2.0
Choose a base ref
...
head repository: airbnb/javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eslint-config-airbnb-v18.2.1
Choose a head ref

Commits on Jun 23, 2020

  1. [eslint config] [*] [deps] update eslint-plugin-import, use valid `…

    …import/no-cycle` `maxDepth` option
    ljharb committed Jun 23, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    c5bee75 View commit details

Commits on Jun 27, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    5124de2 View commit details

Commits on Aug 3, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    1dc71d3 View commit details

Commits on Aug 6, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    3dcc591 View commit details
  2. [eslint config] [*] [dev deps] update @babel/runtime, `eslint-find-…

    …rules`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`
    ljharb committed Aug 6, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    973384b View commit details
  3. 1

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    a24dc34 View commit details

Commits on Aug 27, 2020

  1. [guide] fix dead es-discourse link

    Fixes #2274.
    ljharb committed Aug 27, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    6006d6d View commit details

Commits on Sep 5, 2020

  1. [guide] Fix grammatical errors

    androiddevnotes authored and ljharb committed Sep 5, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    337f607 View commit details

Commits on Sep 23, 2020

  1. [eslint config] [patch] Fixed handle and on ordering in `sort-com…

    …p` rule
    
    - fixes #2116
    alvyn279 authored and ljharb committed Sep 23, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    d3c7b84 View commit details

Commits on Oct 6, 2020

  1. Copy the full SHA
    5ebfe3e View commit details

Commits on Oct 11, 2020

  1. Copy the full SHA
    82170f9 View commit details

Commits on Oct 14, 2020

  1. [guide] add explanation about why to use radix when using parseInt

    I added an explanation at [22.3](https://github.com/airbnb/javascript/blob/master/README.md#coercion--numbers) why to use radix once parseInt, this explanation has been taken from [Mozilla's docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#Octal_interpretations_with_no_radix).
    
    I think it's not clear without an explanation since people can think that it's obvious that string will be parsed to 10 base number, but it's not always the case.
    danielpaz6 authored and ljharb committed Oct 14, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    aa43bb2 View commit details

Commits on Oct 16, 2020

  1. [guide] Better link reference to Drupal's linter

    This link was taken from their Code standard page: https://www.drupal.org/docs/develop/standards/javascript/eslint-settings
    
    The previous link wasn't very informative and required a download process in order to check their standards.
    danielpaz6 authored and ljharb committed Oct 16, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    ee2f22a View commit details

Commits on Oct 22, 2020

  1. [guide] Update reason for preferring object destructuring

    Fixes #2293
    
    The reason for preferring object destructuring is quite narrow in scope. While this guide isn't intended to provide every possible reason for every preference, it perhaps should aim to provide a succinct and compelling reason. The current reasoning could be improved to meet this standard, so I'm proposing adding some additional information to clarify the benefits of what is an often controversial rule (controversial only because its introduction can require many changes in a mature codebase and has no auto fix available).
    michaelaflores authored Oct 22, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2c5c88d View commit details

Commits on Oct 23, 2020

  1. [eslint config] [patch] Fix ignoreNonDOM typo in jsx-a11y/aria-role rule

    This should be `ignoreNonDOM` not `ignoreNonDom` according to [documentation](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md).
    amercier authored and ljharb committed Oct 23, 2020

    Partially verified

    This commit is signed with the committer’s verified signature.
    ljharb’s contribution has been verified via GPG key.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    05c3bb0 View commit details

Commits on Oct 24, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    b30b0e4 View commit details

Commits on Oct 26, 2020

  1. Partially verified

    This commit is signed with the committer’s verified signature.
    ljharb’s contribution has been verified via GPG key.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    8996aa7 View commit details

Commits on Nov 6, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    25b64d7 View commit details
  2. [eslint config] [*] [dev deps] update @babel/runtime, `eslint-find-…

    …rules`, `eslint-plugin-import`
    ljharb committed Nov 6, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    f0492d5 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    e149b05 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    36f23d7 View commit details
  5. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    b7015dd View commit details
  6. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    eee79a5 View commit details
  7. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    e5de51e View commit details
  8. [eslint config] v18.2.1

    ljharb committed Nov 6, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    37d48db View commit details
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -306,7 +306,7 @@ Other Style Guides
```

<a name="objects--rest-spread"></a>
- [3.8](#objects--rest-spread) Prefer the object spread operator over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted.
- [3.8](#objects--rest-spread) Prefer the object spread operator over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread)

```javascript
// very bad
@@ -497,7 +497,7 @@ Other Style Guides
<a name="destructuring--object"></a><a name="5.1"></a>
- [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring)
> Why? Destructuring saves you from creating temporary references for those properties.
> Why? Destructuring saves you from creating temporary references for those properties, and from repetitive access of the object. Repeating object access creates more repetitive code, requires more reading, and creates more opportunities for mistakes. Destructuring objects also provides a single site of definition of the object structure that is used in the block, rather than requiring reading the entire block to determine what is used.
```javascript
// bad
@@ -782,7 +782,7 @@ Other Style Guides
```
<a name="functions--defaults-last"></a><a name="7.9"></a>
- [7.9](#functions--defaults-last) Always put default parameters last.
- [7.9](#functions--defaults-last) Always put default parameters last. eslint: [`default-param-last`](https://eslint.org/docs/rules/default-param-last)
```javascript
// bad
@@ -1662,7 +1662,7 @@ Other Style Guides
<a name="variables--const-let-group"></a><a name="13.3"></a>
- [13.3](#variables--const-let-group) Group all your `const`s and then group all your `let`s.
> Why? This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.
> Why? This is helpful when later on you might need to assign a variable depending on one of the previously assigned variables.
```javascript
// bad
@@ -1859,7 +1859,7 @@ Other Style Guides
## Hoisting
<a name="hoisting--about"></a><a name="14.1"></a>
- [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15).
- [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone). It’s important to know why [typeof is no longer safe](https://web.archive.org/web/20200121061528/http://es-discourse.com/t/why-typeof-is-no-longer-safe/15).
```javascript
// we know this wouldn’t work (assuming there
@@ -3166,6 +3166,8 @@ Other Style Guides
<a name="coercion--numbers"></a><a name="21.3"></a>
- [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](https://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers)
> Why? The `parseInt` function produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix. Leading whitespace in string is ignored. If radix is `undefined` or `0`, it is assumed to be `10` except when the number begins with the character pairs `0x` or `0X`, in which case a radix of 16 is assumed. This differs from ECMAScript 3, which merely discouraged (but allowed) octal interpretation. Many implementations have not adopted this behavior as of 2013. And, because older browsers must be supported, always specify a radix.
```javascript
const inputValue = '4';

@@ -3858,7 +3860,7 @@ Other Style Guides
- **DailyMotion**: [dailymotion/javascript](https://github.com/dailymotion/javascript)
- **DoSomething**: [DoSomething/eslint-config](https://github.com/DoSomething/eslint-config)
- **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript)
- **Drupal**: [www.drupal.org](https://www.drupal.org/project/drupal)
- **Drupal**: [www.drupal.org](https://git.drupalcode.org/project/drupal/blob/8.6.x/core/.eslintrc.json)
- **Ecosia**: [ecosia/javascript](https://github.com/ecosia/javascript)
- **Evernote**: [evernote/javascript-style-guide](https://github.com/evernote/javascript-style-guide)
- **Evolution Gaming**: [evolution-gaming/javascript](https://github.com/evolution-gaming/javascript)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"markdownlint": "^0.20.3",
"markdownlint-cli": "^0.23.1"
"markdownlint": "^0.20.4",
"markdownlint-cli": "^0.23.2"
}
}
8 changes: 8 additions & 0 deletions packages/eslint-config-airbnb-base/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
14.2.1 / 2020-11-06
==================
- [base] `no-restricted-globals`: add better messages (#2320)
- [base] add new core eslint rules, set to off
- [deps] update `confusing-browser-globals`, `object.assign`
- [deps] update `eslint-plugin-import`, use valid `import/no-cycle` `maxDepth` option (#2250, #2249)
- [dev deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-import`

14.2.0 / 2020-06-10
==================
- [new] add `eslint` `v7`
14 changes: 7 additions & 7 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-airbnb-base",
"version": "14.2.0",
"version": "14.2.1",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
@@ -53,27 +53,27 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"@babel/runtime": "^7.8.7",
"@babel/runtime": "^7.12.5",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-find-rules": "^3.5.0",
"eslint-plugin-import": "^2.21.2",
"eslint-find-rules": "^3.6.1",
"eslint-plugin-import": "^2.22.1",
"in-publish": "^2.0.1",
"safe-publish-latest": "^1.1.4",
"tape": "^5.0.1"
},
"peerDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-plugin-import": "^2.21.2"
"eslint-plugin-import": "^2.22.1"
},
"engines": {
"node": ">= 6"
},
"dependencies": {
"confusing-browser-globals": "^1.0.9",
"object.assign": "^4.1.0",
"confusing-browser-globals": "^1.0.10",
"object.assign": "^4.1.2",
"object.entries": "^1.1.2"
}
}
12 changes: 12 additions & 0 deletions packages/eslint-config-airbnb-base/rules/errors.js
Original file line number Diff line number Diff line change
@@ -103,6 +103,11 @@ module.exports = {
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 'error',

// Disallow returning values from Promise executor functions
// https://eslint.org/docs/rules/no-promise-executor-return
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-promise-executor-return': 'off',

// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'error',
@@ -129,6 +134,13 @@ module.exports = {
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 'error',

// Disallow loops with a body that allows only one iteration
// https://eslint.org/docs/rules/no-unreachable-loop
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-unreachable-loop': ['off', {
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
}],

// disallow return/throw/break/continue inside finally blocks
// https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',
2 changes: 1 addition & 1 deletion packages/eslint-config-airbnb-base/rules/imports.js
Original file line number Diff line number Diff line change
@@ -233,7 +233,7 @@ module.exports = {

// Forbid cyclical dependencies between modules
// https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
'import/no-cycle': ['error', { maxDepth: Infinity }],
'import/no-cycle': ['error', { maxDepth: '∞' }],

// Ensures that there are no useless path segments
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
5 changes: 5 additions & 0 deletions packages/eslint-config-airbnb-base/rules/style.js
Original file line number Diff line number Diff line change
@@ -107,8 +107,13 @@ module.exports = {

// Blacklist certain identifiers to prevent them being used
// https://eslint.org/docs/rules/id-blacklist
// TODO: semver-major, remove once eslint v7.4+ is required
'id-blacklist': 'off',

// disallow specified identifiers
// https://eslint.org/docs/rules/id-denylist
'id-denylist': 'off',

// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 'off',
14 changes: 13 additions & 1 deletion packages/eslint-config-airbnb-base/rules/variables.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,19 @@ module.exports = {
'no-label-var': 'error',

// disallow specific globals
'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(confusingBrowserGlobals),
'no-restricted-globals': [
'error',
{
name: 'isFinite',
message:
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
},
{
name: 'isNaN',
message:
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
},
].concat(confusingBrowserGlobals),

// disallow declaration of variables already declared in the outer scope
'no-shadow': 'error',
9 changes: 9 additions & 0 deletions packages/eslint-config-airbnb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
18.2.1 / 2020-11-06
==================
- [patch] remove deprecated `jsx-a11y/accessible-emoji` rule (#2322)
- [patch] Fix ignoreNonDOM typo in jsx-a11y/aria-role rule (#2318)
- [patch] Fixed `handle` and `on` ordering in `sort-comp` rule (#2287)
- [deps] update `eslint-plugin-jsx-a11y`, `eslint-plugin-react`
- [deps] update `eslint-config-airbnb-base`, `object.assign`
- [dev deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`

18.2.0 / 2020-06-18
==================
- [new] add `eslint` `v7` (#2240)
22 changes: 11 additions & 11 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-airbnb",
"version": "18.2.0",
"version": "18.2.1",
"description": "Airbnb's ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
@@ -54,20 +54,20 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^14.2.0",
"object.assign": "^4.1.0",
"eslint-config-airbnb-base": "^14.2.1",
"object.assign": "^4.1.2",
"object.entries": "^1.1.2"
},
"devDependencies": {
"@babel/runtime": "^7.8.7",
"@babel/runtime": "^7.12.5",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-find-rules": "^3.5.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.3.0",
"eslint-plugin-react": "^7.20.0",
"eslint-find-rules": "^3.6.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0",
"in-publish": "^2.0.1",
"react": ">= 0.13.0",
@@ -76,9 +76,9 @@
},
"peerDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.3.0",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0"
},
"engines": {
5 changes: 3 additions & 2 deletions packages/eslint-config-airbnb/rules/react-a11y.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ module.exports = {

// Require ARIA roles to be valid and non-abstract
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }],
'jsx-a11y/aria-role': ['error', { ignoreNonDOM: false }],

// Enforce all aria-* props are valid.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
@@ -180,7 +180,8 @@ module.exports = {

// ensure emoji are accessible
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
'jsx-a11y/accessible-emoji': 'error',
// disabled; rule is deprecated
'jsx-a11y/accessible-emoji': 'off',

// elements with aria-activedescendant must be tabbable
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
1 change: 1 addition & 0 deletions packages/eslint-config-airbnb/rules/react.js
Original file line number Diff line number Diff line change
@@ -244,6 +244,7 @@ module.exports = {
'static-methods',
'instance-variables',
'lifecycle',
'/^handle.+$/',
'/^on.+$/',
'getters',
'setters',
47 changes: 46 additions & 1 deletion packages/eslint-config-airbnb/test/test-react-order.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ ${body}}
`;
}

test('validate react prop order', (t) => {
test('validate react methods order', (t) => {
t.test('make sure our eslintrc has React and JSX linting dependencies', (t) => {
t.plan(2);
t.deepEqual(reactRules.plugins, ['react']);
@@ -44,6 +44,8 @@ test('validate react prop order', (t) => {
t.plan(3);
const result = lint(wrapComponent(`
componentDidMount() {}
handleSubmit() {}
onButtonAClick() {}
setFoo() {}
getFoo() {}
setBar() {}
@@ -88,4 +90,47 @@ test('validate react prop order', (t) => {
t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});

t.test('order: when handler method with `handle` prefix after method with `on` prefix', (t) => {
t.plan(2);
const result = lint(wrapComponent(`
componentDidMount() {}
onButtonAClick() {}
handleSubmit() {}
setFoo() {}
getFoo() {}
render() { return <div />; }
`));

t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});

t.test('order: when lifecycle methods after event handler methods', (t) => {
t.plan(2);
const result = lint(wrapComponent(`
handleSubmit() {}
componentDidMount() {}
setFoo() {}
getFoo() {}
render() { return <div />; }
`));

t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});

t.test('order: when event handler methods after getters and setters', (t) => {
t.plan(2);
const result = lint(wrapComponent(`
componentDidMount() {}
setFoo() {}
getFoo() {}
handleSubmit() {}
render() { return <div />; }
`));

t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
});
Loading