|
| 1 | +/** |
| 2 | + * @fileoverview Tests for jsx-no-undef |
| 3 | + * @author Yannick Croissant |
| 4 | + */ |
| 5 | + |
| 6 | +'use strict'; |
| 7 | + |
| 8 | +// ----------------------------------------------------------------------------- |
| 9 | +// Requirements |
| 10 | +// ----------------------------------------------------------------------------- |
| 11 | + |
| 12 | +var eslint = require('eslint').linter; |
| 13 | +var ESLintTester = require('eslint-tester'); |
| 14 | + |
| 15 | +// ----------------------------------------------------------------------------- |
| 16 | +// Tests |
| 17 | +// ----------------------------------------------------------------------------- |
| 18 | + |
| 19 | +var eslintTester = new ESLintTester(eslint); |
| 20 | +eslint.defineRule('no-undef', require('eslint/lib/rules/no-undef')); |
| 21 | +eslintTester.addRuleTest('lib/rules/jsx-no-undef', { |
| 22 | + valid: [{ |
| 23 | + code: '/*eslint no-undef:1*/ var React, App; React.render(<App />);', |
| 24 | + args: [1, {vars: 'all'}], |
| 25 | + ecmaFeatures: {modules: true, jsx: true} |
| 26 | + }, { |
| 27 | + code: '/*eslint no-undef:1*/ var React, App; React.render(<App />);', |
| 28 | + args: [1, {vars: 'all'}], |
| 29 | + ecmaFeatures: {jsx: true} |
| 30 | + }, { |
| 31 | + code: '/*eslint no-undef:1*/ var React; React.render(<img />);', |
| 32 | + args: [1, {vars: 'all'}], |
| 33 | + ecmaFeatures: {jsx: true} |
| 34 | + }, { |
| 35 | + code: '/*eslint no-undef:1*/ var React; React.render(<x-gif />);', |
| 36 | + args: [1, {vars: 'all'}], |
| 37 | + ecmaFeatures: {jsx: true} |
| 38 | + }], |
| 39 | + invalid: [{ |
| 40 | + code: '/*eslint no-undef:1*/ var React; React.render(<App />);', |
| 41 | + args: [1, {vars: 'all'}], |
| 42 | + errors: [{ |
| 43 | + message: '\'App\' is not defined.' |
| 44 | + }], |
| 45 | + ecmaFeatures: {jsx: true} |
| 46 | + }] |
| 47 | +}); |
0 commit comments