Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] no-typos: move a valid case into valid section #2678

Merged
merged 1 commit into from Jun 27, 2020

Conversation

toshi-toma
Copy link
Contributor

It seems CI is failing.

  4345 passing (12s)
  1 failing
  1) no-typos
       invalid
         
     import 'react';
     class Component extends React.Component {};
   :
     AssertionError [ERR_ASSERTION]: Invalid cases must have at least one error
      at testInvalidTemplate (node_modules/eslint/lib/rule-tester/rule-tester.js:648:24)
      at Context.RuleTester.it (node_modules/eslint/lib/rule-tester/rule-tester.js:883:25)
      at processImmediate (internal/timers.js:443:21)

I moved a valid case into a valid section.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing that! However, this is definitely an invalid test case; import 'react' does not bring React into scope.

@toshi-toma
Copy link
Contributor Author

toshi-toma commented Jun 27, 2020

@ljharb

Oh, Thanks. I understand.
But This case does not report in no-typoes rule. So, We can't fill in the errors field. ESLint will throw an error (AssertionError [ERR_ASSERTION]: Invalid cases must have at least one error)

import 'react';
class Component extends React.Component {};

I have some options.

Option 1. delete the case 😓

Option 2. Add a code that fails.

e.g

{
    code: `
   import 'react'
     import PropTypes from 'prop-types';
     class Component extends React.Component {};
     Component.propTypes = {
       a: PropTypes.string.isrequired,
       b: PropTypes.shape({
         c: PropTypes.number
       }).isrequired
     }
   `,
    parser: parsers.BABEL_ESLINT,
    parserOptions,
    errors: [{
      message: 'Typo in prop type chain qualifier: isrequired'
    }, {
      message: 'Typo in prop type chain qualifier: isrequired'
    }]
},

Do you have any good ideas?

@ljharb
Copy link
Member

ljharb commented Jun 27, 2020

import 'react' should be the typo.

@toshi-toma
Copy link
Contributor Author

no-typos seems does not report ImportDeclaration. only PropTypes, lifecycle methods, and class properties...

Do you think should I add the report for ImportDeclaration??
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-typos.md

@ljharb
Copy link
Member

ljharb commented Jun 27, 2020

Hmm - looks like the test fails in eslint v7.3 but passes in eslint v7.2.

@ljharb
Copy link
Member

ljharb commented Jun 27, 2020

I'll just pin travis-ci to v7.2 for now, but we should fix the real bug.

@ljharb
Copy link
Member

ljharb commented Jun 27, 2020

(maybe i have to pin to 7.1, since 7.2 breaks in older nodes)

@ljharb ljharb force-pushed the fix-failed-test-no-typos branch 3 times, most recently from 3aa8bf0 to a4025bd Compare June 27, 2020 08:00
@ljharb ljharb merged commit a4025bd into jsx-eslint:master Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants