style: lint .tsx (#530)

Fixes #528.
pull/529/head
Shahar Dawn Or 5 years ago committed by GitHub
parent 6eacf72763
commit 14d7e0af25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,7 @@
"scripts": {
"docs": "remark . --output",
"check-clean": "git diff --exit-code",
"lint:js": "eslint --ignore-path .gitignore --ext .js,.ts .",
"lint:js": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"lint:editorconfig": "editorconfig-checker",
"lint": "run-s lint:editorconfig lint:js",
"unit": "karma start",

@ -1,19 +1,19 @@
import * as assert from 'assert';
import {jsx} from '../jsx';
import { jsx } from '../jsx';
describe('snabbdom', function() {
describe('jsx', function() {
it('can be used as a jsxFactory method', function() {
describe('snabbdom', function () {
describe('jsx', function () {
it('can be used as a jsxFactory method', function () {
const vnode = <div title="Hello World">Hello World</div>;
assert.equal(JSON.stringify(vnode), JSON.stringify({
sel: 'div',
data: {title: 'Hello World'},
data: { title: 'Hello World' },
text: 'Hello World',
}));
});
it('creates text property for text only child', function() {
it('creates text property for text only child', function () {
const vnode = <div>foo bar</div>;
assert.equal(JSON.stringify(vnode), JSON.stringify({
@ -23,20 +23,20 @@ describe('snabbdom', function() {
}));
});
it('creates an array of children for multiple children', function() {
it('creates an array of children for multiple children', function () {
const vnode = <div>{'foo'}{'bar'}</div>;
assert.equal(JSON.stringify(vnode), JSON.stringify({
sel: 'div',
data: {},
children: [
{text: 'foo'},
{text: 'bar'},
{ text: 'foo' },
{ text: 'bar' },
]
}));
});
it('flattens children', function() {
it('flattens children', function () {
const vnode = (
<section>
<h1>A Heading</h1>
@ -49,19 +49,19 @@ describe('snabbdom', function() {
sel: 'section',
data: {},
children: [
{sel: 'h1', data: {}, text: 'A Heading'},
{text: 'some description'},
{sel: 'span', data: {}, text: 'part1'},
{sel: 'span', data: {}, text: 'part2'},
{ sel: 'h1', data: {}, text: 'A Heading' },
{ text: 'some description' },
{ sel: 'span', data: {}, text: 'part1' },
{ sel: 'span', data: {}, text: 'part2' },
],
}));
});
it('removes falsey children', function() {
it('removes falsey children', function () {
const showLogin = false;
const showCaptcha = false;
const loginAttempts = 0;
const userName = ``;
const userName = '';
const profilePic = undefined;
const isLoggedIn = true;
const vnode = (
@ -80,20 +80,20 @@ describe('snabbdom', function() {
sel: 'div',
data: {},
children: [
{text: 'Login Form'},
{text: 'Login Attempts: '},
{text: '0'},
{text: 'Logged In: '},
{text: 'true'},
{ text: 'Login Form' },
{ text: 'Login Attempts: ' },
{ text: '0' },
{ text: 'Logged In: ' },
{ text: 'true' },
],
}));
});
it('works with a function component', function() {
const Part = ({part}: {part: string}) => <span>{part}</span>
it('works with a function component', function () {
const Part = ({ part }: {part: string}) => <span>{part}</span>
const vnode = (
<div>
<a attrs={{href: 'https://github.com/snabbdom/snabbdom'}}>Snabbdom</a>
<a attrs={{ href: 'https://github.com/snabbdom/snabbdom' }}>Snabbdom</a>
and tsx
{['work', 'like', 'a', 'charm!'].map(part => <Part part={part}></Part>)}
{'💃🕺🎉'}
@ -104,13 +104,13 @@ describe('snabbdom', function() {
sel: 'div',
data: {},
children: [
{sel: 'a', data: {attrs: {href: 'https://github.com/snabbdom/snabbdom'}}, text: 'Snabbdom'},
{text: 'and tsx'},
{sel: 'span', data: {}, text: 'work'},
{sel: 'span', data: {}, text: 'like'},
{sel: 'span', data: {}, text: 'a'},
{sel: 'span', data: {}, text: 'charm!'},
{text: '💃🕺🎉'},
{ sel: 'a', data: { attrs: { href: 'https://github.com/snabbdom/snabbdom' } }, text: 'Snabbdom' },
{ text: 'and tsx' },
{ sel: 'span', data: {}, text: 'work' },
{ sel: 'span', data: {}, text: 'like' },
{ sel: 'span', data: {}, text: 'a' },
{ sel: 'span', data: {}, text: 'charm!' },
{ text: '💃🕺🎉' },
],
}));
})

Loading…
Cancel
Save