Permalink
Browse files

Upgrade eslint-config-standard: 11.0.0 → 12.0.0 (major) (#69)

* Update eslint-config-standard to version 12.0.0

* ⬆️ Update codebase for lint
  • Loading branch information...
depfu authored and wei committed Jan 8, 2019
1 parent fb517da commit 5cc1ea81210fb2dc4dd2e93803e92c4be8829474

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -18,7 +18,7 @@
"devDependencies": {
"copy-webpack-plugin": "^4.6.0",
"eslint": "^5.12.0",
"eslint-config-standard": "^11.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-config-standard-preact": "^1.1.6",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-json": "^1.3.2",
@@ -10,7 +10,7 @@ export default class Heading extends Component {
if (!owner || !repo) return null

return heading
? <h1 class={classnames('ni-heading', style['_ni-heading'])} dangerouslySetInnerHTML={{__html: heading}} />
? <h1 class={classnames('ni-heading', style['_ni-heading'])} dangerouslySetInnerHTML={{ __html: heading }} />
: <h1 class={classnames('ni-heading', style['_ni-heading'])}>
<a class={classnames('ni-repo-link', style['_ni-repo-link'])} href={getGithubUrl(owner)} target='_blank'>{owner}</a>
<span>/</span>
@@ -21,10 +21,10 @@ export default class Index extends Component {
fetchUserInfo () {
getUserInfo()
.then(user => {
this.setState({githubUser: user})
this.setState({ githubUser: user })
})
.catch(() => {
this.setState({githubUser: false})
this.setState({ githubUser: false })
})
}

@@ -10,7 +10,7 @@ export default class Input extends Component {

getLabel () {
const labelText = (this.props.config && this.props.config.label) || ''
return <label class={classnames('ni-label', style['_ni-label'], {'ni-empty-label': !labelText})}>{labelText}</label>
return <label class={classnames('ni-label', style['_ni-label'], { 'ni-empty-label': !labelText })}>{labelText}</label>
}

getInput () {
@@ -55,12 +55,12 @@ export default class Input extends Component {
case 'submit': {
const { submit, disabled } = config
return <button type={type} name={name} id={id} class={classnames('ni-input', `ni-${type}`, style[`_ni-input`], style[`_ni-${type}`], className)}
title={title} disabled={disabled} dangerouslySetInnerHTML={{__html: submit || 'Submit'}} />
title={title} disabled={disabled} dangerouslySetInnerHTML={{ __html: submit || 'Submit' }} />
}
case 'html': {
const { html } = config
return <div id={id} class={classnames('ni-input', `ni-${type}`, style[`_ni-input`], style[`_ni-${type}`], className)} title={title}
dangerouslySetInnerHTML={{__html: html}} />
dangerouslySetInnerHTML={{ __html: html }} />
}
default: {
return null
@@ -27,7 +27,7 @@ export default class IssueDirect extends Component {
</header>
<br /><br />
<footer class={classnames('ni-footer', style['_ni-footer'], 'text-center')}>
<Input config={{type: 'submit', submit: 'Submit New Issue on Github'}} />
<Input config={{ type: 'submit', submit: 'Submit New Issue on Github' }} />
</footer>
<br />
</form>
@@ -23,7 +23,7 @@ export default class IssueLoading extends Component {
</header>
<br /><br />
<footer class={classnames('ni-footer', style['_ni-footer'], 'text-center')}>
<Input config={{type: 'submit', submit: props.loading ? 'Loading...' : 'New Issue', disabled: props.loading}} />
<Input config={{ type: 'submit', submit: props.loading ? 'Loading...' : 'New Issue', disabled: props.loading }} />
</footer>
<br />
</form>
@@ -38,7 +38,7 @@ export default class Main extends Component {
return (
<form class={classnames('ni-form', style['_ni-form'])} onSubmit={e => this.handleSubmit(e)}>
{ typeof customHeader === 'string'
? <header class={classnames('ni-header', style['_ni-header'], 'ni-custom-header')} dangerouslySetInnerHTML={{__html: customHeader}} />
? <header class={classnames('ni-header', style['_ni-header'], 'ni-custom-header')} dangerouslySetInnerHTML={{ __html: customHeader }} />
: <header class={classnames('ni-header', style['_ni-header'])}>
<Heading config={Object.assign({ owner, repo }, { heading: heading })} />
</header> }
@@ -48,9 +48,9 @@ export default class Main extends Component {
<section class='ni-body-inputs'>
{ body.map((c, idx) => <Input ref={r => { this.bodyRefs[idx] = r }} config={c} />) }
</section>
{ typeof customFooter === 'string' ? <footer class={classnames('ni-footer', style['_ni-footer'], 'ni-custom-footer')} dangerouslySetInnerHTML={{__html: customFooter}} /> : null }
{ typeof customCSS === 'string' ? <style class='ni-custom-css' dangerouslySetInnerHTML={{__html: customCSS}} /> : null }
{ typeof customJS === 'string' ? <script class='ni-custom-js' dangerouslySetInnerHTML={{__html: customJS}} /> : null }
{ typeof customFooter === 'string' ? <footer class={classnames('ni-footer', style['_ni-footer'], 'ni-custom-footer')} dangerouslySetInnerHTML={{ __html: customFooter }} /> : null }
{ typeof customCSS === 'string' ? <style class='ni-custom-css' dangerouslySetInnerHTML={{ __html: customCSS }} /> : null }
{ typeof customJS === 'string' ? <script class='ni-custom-js' dangerouslySetInnerHTML={{ __html: customJS }} /> : null }
</form>
)
}
@@ -33,7 +33,7 @@ const setLocalAccessToken = (token = '') => {
const triggerLogin = () => {
return new Promise((resolve, reject) => {
new Authenticator({ site_id: window.location.host.match(/localhost/i) && 'new-issue.org' })
.authenticate({provider: 'github', scope: 'public_repo'},
.authenticate({ provider: 'github', scope: 'public_repo' },
(err, data) => {
if (err) return reject(err)
setLocalAccessToken(data.token)
@@ -1,5 +1,5 @@
import Ajv from 'ajv'
const ajv = new Ajv({allErrors: true})
const ajv = new Ajv({ allErrors: true })

const validateSchema = (json) => {
try {
@@ -11,8 +11,8 @@ describe('Heading', () => {
undefined,
null,
{},
{owner: 'test'},
{repo: 'test'},
{ owner: 'test' },
{ repo: 'test' },
].forEach(config => {
const context = shallow(<Heading config={config} />)

@@ -346,7 +346,7 @@ describe(`Input - input type: submit`, () => {
expect(buttonField.attr('disabled')).toBeFalsy()
}
// TODO Test html after rendering
expect(buttonField.attr('dangerouslySetInnerHTML')).toEqual({__html: config.submit || 'Submit'})
expect(buttonField.attr('dangerouslySetInnerHTML')).toEqual({ __html: config.submit || 'Submit' })
expect(context).toMatchSnapshot()
expect(context.component().output())
.toEqual({
@@ -393,7 +393,7 @@ describe(`Input - input type: html`, () => {
}
expect(htmlField.attr('title')).toBe(config.title)
// TODO Test html after rendering
expect(htmlField.attr('dangerouslySetInnerHTML')).toEqual({__html: config.html})
expect(htmlField.attr('dangerouslySetInnerHTML')).toEqual({ __html: config.html })
expect(context).toMatchSnapshot()
expect(context.component().output())
.toEqual({
@@ -38,7 +38,7 @@ describe('IssueDirect', () => {
const context = shallow(<IssueDirect owner={owner} repo={repo} config={config} />)
expect(context).toMatchSnapshot()
const preventDefault = jest.fn()
context.component().handleSubmit({preventDefault: preventDefault})
context.component().handleSubmit({ preventDefault: preventDefault })
expect(preventDefault).toBeCalled()
expect(window.location.assign).toBeCalledWith(`${getGithubIssuesUrl(owner, repo)}`)
})
@@ -34,7 +34,7 @@ describe('IssueLoading', () => {
const context1 = shallow(<IssueLoading owner={owner} repo={repo} loading handleLogin={handleLogin1} config={config} />)
expect(context1).toMatchSnapshot()
const preventDefault = jest.fn()
context1.component().handleSubmit({preventDefault: preventDefault})
context1.component().handleSubmit({ preventDefault: preventDefault })
expect(preventDefault).toBeCalled()
expect(handleLogin1).toBeCalled()

@@ -40,7 +40,7 @@ describe('Main', () => {
expect(context).toMatchSnapshot()

const preventDefault = jest.fn()
context.component().handleSubmit({preventDefault: preventDefault})
context.component().handleSubmit({ preventDefault: preventDefault })
expect(preventDefault).toBeCalled()
})
})
@@ -74,8 +74,8 @@ describe('gh-helper getUserInfo', () => {
describe('gh-helper buildIssueTitle', () => {
it('should return built issue title', () => {
expect(buildIssueTitle()).toBe('')
expect(buildIssueTitle([{label: 'label 1\n', value: 'value 1'}])).toMatchSnapshot()
expect(buildIssueTitle([{label: 'label 1\n', value: 'value 1'}, {label: 'label 2\n', value: 'value 2'}]))
expect(buildIssueTitle([{ label: 'label 1\n', value: 'value 1' }])).toMatchSnapshot()
expect(buildIssueTitle([{ label: 'label 1\n', value: 'value 1' }, { label: 'label 2\n', value: 'value 2' }]))
.toMatchSnapshot()
})
})
@@ -84,19 +84,19 @@ describe('gh-helper buildIssueBody', () => {
it('should return built issue body', () => {
expect(buildIssueBody())
.toMatchSnapshot()
expect(buildIssueBody([{label: 'label 1\n', value: 'value 1'}]))
expect(buildIssueBody([{ label: 'label 1\n', value: 'value 1' }]))
.toMatchSnapshot()
expect(buildIssueBody([{label: 'label 1\n', value: 'value 1'}, {label: 'label 2\n', value: 'value 2'}]))
expect(buildIssueBody([{ label: 'label 1\n', value: 'value 1' }, { label: 'label 2\n', value: 'value 2' }]))
.toMatchSnapshot()
expect(buildIssueBody([{}, {label: 'label 1\n', value: null}, {label: 'label 2\n'}, {label: 'label 3\n', value: 'value 3'}]))
expect(buildIssueBody([{}, { label: 'label 1\n', value: null }, { label: 'label 2\n' }, { label: 'label 3\n', value: 'value 3' }]))
.toMatchSnapshot()
expect(buildIssueBody([{label: 'label 1\n', value: ''}, {label: 'label 2\n', value: 'value 2'}], {hideEmpty: true}))
expect(buildIssueBody([{ label: 'label 1\n', value: '' }, { label: 'label 2\n', value: 'value 2' }], { hideEmpty: true }))
.toMatchSnapshot()
expect(buildIssueBody([{label: 'label 1\n'}, {label: 'label 2\n', value: 'value 2'}], {hideEmpty: true}))
expect(buildIssueBody([{ label: 'label 1\n' }, { label: 'label 2\n', value: 'value 2' }], { hideEmpty: true }))
.toMatchSnapshot()
expect(buildIssueBody([{value: 'value 1'}, {label: 'label 2\n', value: 'value 2'}], {hideEmpty: true}))
expect(buildIssueBody([{ value: 'value 1' }, { label: 'label 2\n', value: 'value 2' }], { hideEmpty: true }))
.toMatchSnapshot()
expect(buildIssueBody([{label: null, value: 'value 1'}, {label: 'label 2\n', value: 'value 2'}], {hideEmpty: true}))
expect(buildIssueBody([{ label: null, value: 'value 1' }, { label: 'label 2\n', value: 'value 2' }], { hideEmpty: true }))
.toMatchSnapshot()
})
})
@@ -6,11 +6,11 @@ describe('validate new-issue json schema', () => {
it('should not pass validation if json is invalid', () => {
expect(validateSchema()).toBe(false)
expect(validateSchema({})).toBe(false)
expect(validateSchema({no_version: true})).toBe(false)
expect(validateSchema({ no_version: true })).toBe(false)
expect(validateSchema('')).toBe(false)
expect(validateSchema(123)).toBe(false)
expect(validateSchema({version: 'x.x'})).toBe(false)
expect(validateSchema({version: '1.0'})).toBe(false)
expect(validateSchema({ version: 'x.x' })).toBe(false)
expect(validateSchema({ version: '1.0' })).toBe(false)
})

test('example jsons should pass validation', () => {

0 comments on commit 5cc1ea8

Please sign in to comment.