123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * @fileoverview Validate closing tag location in JSX
- * @author Ross Solomon
- */
- 'use strict';
- // ------------------------------------------------------------------------------
- // Requirements
- // ------------------------------------------------------------------------------
- const rule = require('../../../lib/rules/jsx-closing-tag-location');
- const RuleTester = require('eslint').RuleTester;
- const parserOptions = {
- sourceType: 'module',
- ecmaFeatures: {
- jsx: true
- }
- };
- const MESSAGE_MATCH_INDENTATION = [{message: 'Expected closing tag to match indentation of opening.'}];
- const MESSAGE_OWN_LINE = [{message: 'Closing tag of a multiline JSX expression must be on its own line.'}];
- // ------------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------------
- const ruleTester = new RuleTester({parserOptions});
- ruleTester.run('jsx-closing-tag-location', rule, {
- valid: [{
- code: `
- <App>
- foo
- </App>
- `
- }, {
- code: `
- <App>foo</App>
- `
- }],
- invalid: [{
- code: `
- <App>
- foo
- </App>
- `,
- output: `
- <App>
- foo
- </App>
- `,
- errors: MESSAGE_MATCH_INDENTATION
- }, {
- code: `
- <App>
- foo</App>
- `,
- output: `
- <App>
- foo
- </App>
- `,
- errors: MESSAGE_OWN_LINE
- }]
- });
|