diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-12-22 11:10:36 +0900 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-22 11:10:36 +0900 | 
| commit | b1a6f374dca078dee2406ebe049715b826e37ca2 (patch) | |
| tree | 5367c48648e2018f55f12d847baba94559e10040 /src/settings | |
| parent | b2dcdedad729ff7087867da50e20578f9fc8fb29 (diff) | |
| parent | da72c2ddd916d79d134662e3985b53a4ac78af7a (diff) | |
Merge pull request #690 from ueokande/eslint-and-prettier
Eslint and prettier
Diffstat (limited to 'src/settings')
| -rw-r--r-- | src/settings/actions/setting.ts | 8 | ||||
| -rw-r--r-- | src/settings/components/form/BlacklistForm.tsx | 6 | ||||
| -rw-r--r-- | src/settings/components/form/KeymapsForm.tsx | 4 | ||||
| -rw-r--r-- | src/settings/components/form/PartialBlacklistForm.tsx | 10 | ||||
| -rw-r--r-- | src/settings/components/form/PropertiesForm.tsx | 10 | ||||
| -rw-r--r-- | src/settings/components/form/SearchForm.tsx | 12 | ||||
| -rw-r--r-- | src/settings/components/index.tsx | 18 | ||||
| -rw-r--r-- | src/settings/components/ui/AddButton.tsx | 3 | ||||
| -rw-r--r-- | src/settings/components/ui/DeleteButton.tsx | 3 | ||||
| -rw-r--r-- | src/settings/components/ui/Input.tsx | 14 | ||||
| -rw-r--r-- | src/settings/index.tsx | 2 | ||||
| -rw-r--r-- | src/settings/storage.ts | 2 | 
12 files changed, 45 insertions, 47 deletions
| diff --git a/src/settings/actions/setting.ts b/src/settings/actions/setting.ts index 9404791..589ec36 100644 --- a/src/settings/actions/setting.ts +++ b/src/settings/actions/setting.ts @@ -5,7 +5,7 @@ import SettingData, {  } from '../../shared/SettingData';  const load = async(): Promise<actions.SettingAction> => { -  let data = await storages.load(); +  const data = await storages.load();    return set(data);  }; @@ -29,7 +29,7 @@ const save = async(data: SettingData): Promise<actions.SettingAction> => {  const switchToForm = (json: JSONTextSettings): actions.SettingAction => {    try {      // toSettings exercise validation -    let form = FormSettings.fromSettings(json.toSettings()); +    const form = FormSettings.fromSettings(json.toSettings());      return {        type: actions.SETTING_SWITCH_TO_FORM,        form, @@ -44,7 +44,7 @@ const switchToForm = (json: JSONTextSettings): actions.SettingAction => {  };  const switchToJson = (form: FormSettings): actions.SettingAction => { -  let json = JSONTextSettings.fromSettings(form.toSettings()); +  const json = JSONTextSettings.fromSettings(form.toSettings());    return {      type: actions.SETTING_SWITCH_TO_JSON,      json, @@ -52,7 +52,7 @@ const switchToJson = (form: FormSettings): actions.SettingAction => {  };  const set = (data: SettingData): actions.SettingAction => { -  let source = data.getSource(); +  const source = data.getSource();    switch (source) {    case SettingSource.JSON:      return { diff --git a/src/settings/components/form/BlacklistForm.tsx b/src/settings/components/form/BlacklistForm.tsx index 4e96cbf..51c32f4 100644 --- a/src/settings/components/form/BlacklistForm.tsx +++ b/src/settings/components/form/BlacklistForm.tsx @@ -43,9 +43,9 @@ class BlacklistForm extends React.Component<Props> {    }    bindValue(e: any) { -    let name = e.target.name; -    let index = e.target.getAttribute('data-index'); -    let items = this.props.value.items; +    const name = e.target.name; +    const index = e.target.getAttribute('data-index'); +    const items = this.props.value.items;      if (name === 'url') {        items[index] = new BlacklistItem(e.target.value, false, []); diff --git a/src/settings/components/form/KeymapsForm.tsx b/src/settings/components/form/KeymapsForm.tsx index 94934ae..dc74de3 100644 --- a/src/settings/components/form/KeymapsForm.tsx +++ b/src/settings/components/form/KeymapsForm.tsx @@ -18,14 +18,14 @@ class KeymapsForm extends React.Component<Props> {    };    render() { -    let values = this.props.value.toJSON(); +    const values = this.props.value.toJSON();      return <div className='form-keymaps-form'>        {          keymaps.fields.map((group, index) => {            return <div key={index} className='form-keymaps-form-field-group'>              {                group.map(([name, label]) => { -                let value = values[name] || ''; +                const value = values[name] || '';                  return <Input                    type='text' id={name} name={name} key={name}                    label={label} value={value} diff --git a/src/settings/components/form/PartialBlacklistForm.tsx b/src/settings/components/form/PartialBlacklistForm.tsx index 0702913..1807e28 100644 --- a/src/settings/components/form/PartialBlacklistForm.tsx +++ b/src/settings/components/form/PartialBlacklistForm.tsx @@ -52,15 +52,15 @@ class PartialBlacklistForm extends React.Component<Props> {    }    bindValue(e: any) { -    let name = e.target.name; -    let index = e.target.getAttribute('data-index'); -    let items = this.props.value.items; +    const name = e.target.name; +    const index = e.target.getAttribute('data-index'); +    const items = this.props.value.items;      if (name === 'url') { -      let current = items[index]; +      const current = items[index];        items[index] = new BlacklistItem(e.target.value, true, current.keys);      } else if (name === 'keys') { -      let current = items[index]; +      const current = items[index];        items[index] = new BlacklistItem(          current.pattern, true, e.target.value.split(','));      } else if (name === 'add') { diff --git a/src/settings/components/form/PropertiesForm.tsx b/src/settings/components/form/PropertiesForm.tsx index db8c8e5..e648971 100644 --- a/src/settings/components/form/PropertiesForm.tsx +++ b/src/settings/components/form/PropertiesForm.tsx @@ -17,13 +17,13 @@ class PropertiesForm extends React.Component<Props> {    };    render() { -    let types = this.props.types; -    let values = this.props.value; +    const types = this.props.types; +    const values = this.props.value;      return <div className='form-properties-form'>        {          Object.keys(types).map((name) => { -          let type = types[name]; +          const type = types[name];            let inputType = '';            let onChange = this.bindValue.bind(this);            if (type === 'string') { @@ -59,8 +59,8 @@ class PropertiesForm extends React.Component<Props> {    }    bindValue(e: React.ChangeEvent<HTMLInputElement>) { -    let name = e.target.name; -    let next = { ...this.props.value }; +    const name = e.target.name; +    const next = { ...this.props.value };      if (e.target.type.toLowerCase() === 'checkbox') {        next[name] = e.target.checked;      } else if (e.target.type.toLowerCase() === 'number') { diff --git a/src/settings/components/form/SearchForm.tsx b/src/settings/components/form/SearchForm.tsx index 0aaf6fd..5dc786b 100644 --- a/src/settings/components/form/SearchForm.tsx +++ b/src/settings/components/form/SearchForm.tsx @@ -18,7 +18,7 @@ class SearchForm extends React.Component<Props> {    };    render() { -    let value = this.props.value.toJSON(); +    const value = this.props.value.toJSON();      return <div className='form-search-form'>        <div className='form-search-form-header'>          <div className='column-name'>Name</div> @@ -56,10 +56,10 @@ class SearchForm extends React.Component<Props> {    // eslint-disable-next-line max-statements    bindValue(e: any) { -    let value = this.props.value.toJSON(); -    let name = e.target.name; -    let index = Number(e.target.getAttribute('data-index')); -    let next: typeof value = { +    const value = this.props.value.toJSON(); +    const name = e.target.name; +    const index = Number(e.target.getAttribute('data-index')); +    const next: typeof value = {        default: value.default,        engines: value.engines.slice(),      }; @@ -76,7 +76,7 @@ class SearchForm extends React.Component<Props> {      } else if (name === 'delete' && value.engines.length > 1) {        next.engines.splice(index, 1);        if (value.engines[index][0] === value.default) { -        let nextIndex = Math.min(index, next.engines.length - 1); +        const nextIndex = Math.min(index, next.engines.length - 1);          next.default = next.engines[nextIndex][0];        }      } diff --git a/src/settings/components/index.tsx b/src/settings/components/index.tsx index 3eb2dbe..f4f0326 100644 --- a/src/settings/components/index.tsx +++ b/src/settings/components/index.tsx @@ -96,7 +96,7 @@ class SettingsComponent extends React.Component<Props> {    render() {      let fields = null; -    let disabled = this.props.error.length > 0; +    const disabled = this.props.error.length > 0;      if (this.props.source === 'form') {        fields = this.renderFormFields(this.props.form!!);      } else if (this.props.source === 'json') { @@ -131,7 +131,7 @@ class SettingsComponent extends React.Component<Props> {    }    bindKeymapsForm(value: FormKeymaps) { -    let data = new SettingData({ +    const data = new SettingData({        source: this.props.source,        form: (this.props.form as FormSettings).buildWithKeymaps(value),      }); @@ -139,7 +139,7 @@ class SettingsComponent extends React.Component<Props> {    }    bindSearchForm(value: any) { -    let data = new SettingData({ +    const data = new SettingData({        source: this.props.source,        form: (this.props.form as FormSettings).buildWithSearch(          FormSearch.fromJSON(value)), @@ -148,7 +148,7 @@ class SettingsComponent extends React.Component<Props> {    }    bindBlacklistForm(blacklist: Blacklist) { -    let data = new SettingData({ +    const data = new SettingData({        source: this.props.source,        form: (this.props.form as FormSettings).buildWithBlacklist(blacklist),      }); @@ -156,7 +156,7 @@ class SettingsComponent extends React.Component<Props> {    }    bindPropertiesForm(value: any) { -    let data = new SettingData({ +    const data = new SettingData({        source: this.props.source,        form: (this.props.form as FormSettings).buildWithProperties(          Properties.fromJSON(value)) @@ -165,7 +165,7 @@ class SettingsComponent extends React.Component<Props> {    }    bindJson(_name: string, value: string) { -    let data = new SettingData({ +    const data = new SettingData({        source: this.props.source,        json: JSONTextSettings.fromText(value),      }); @@ -173,13 +173,13 @@ class SettingsComponent extends React.Component<Props> {    }    bindSource(_name: string, value: string) { -    let from = this.props.source; +    const from = this.props.source;      if (from === 'form' && value === 'json') {        this.props.dispatch(settingActions.switchToJson(          this.props.form as FormSettings));        this.save();      } else if (from === 'json' && value === 'form') { -      let b = window.confirm(DO_YOU_WANT_TO_CONTINUE); +      const b = window.confirm(DO_YOU_WANT_TO_CONTINUE);        if (!b) {          this.forceUpdate();          return; @@ -191,7 +191,7 @@ class SettingsComponent extends React.Component<Props> {    }    save() { -    let { source, json, form } = this.props.store.getState(); +    const { source, json, form } = this.props.store.getState();      this.props.dispatch(settingActions.save(        new SettingData({ source, json, form }),      )); diff --git a/src/settings/components/ui/AddButton.tsx b/src/settings/components/ui/AddButton.tsx index 0577068..bb76d08 100644 --- a/src/settings/components/ui/AddButton.tsx +++ b/src/settings/components/ui/AddButton.tsx @@ -1,8 +1,7 @@  import './AddButton.scss';  import React from 'react'; -interface Props extends React.AllHTMLAttributes<HTMLInputElement> { -} +type Props = React.AllHTMLAttributes<HTMLInputElement>;  class AddButton extends React.Component<Props> {    render() { diff --git a/src/settings/components/ui/DeleteButton.tsx b/src/settings/components/ui/DeleteButton.tsx index f0ef6c9..e666426 100644 --- a/src/settings/components/ui/DeleteButton.tsx +++ b/src/settings/components/ui/DeleteButton.tsx @@ -1,8 +1,7 @@  import './DeleteButton.scss';  import React from 'react'; -interface Props extends React.AllHTMLAttributes<HTMLInputElement> { -} +type Props = React.AllHTMLAttributes<HTMLInputElement>;  class DeleteButton extends React.Component<Props> {    render() { diff --git a/src/settings/components/ui/Input.tsx b/src/settings/components/ui/Input.tsx index b7593b9..69c14b3 100644 --- a/src/settings/components/ui/Input.tsx +++ b/src/settings/components/ui/Input.tsx @@ -13,8 +13,8 @@ interface Props extends React.AllHTMLAttributes<HTMLElement> {  class Input extends React.Component<Props> {    renderText(props: Props) { -    let inputClassName = props.error ? 'input-error' : ''; -    let pp = { ...props }; +    const inputClassName = props.error ? 'input-error' : ''; +    const pp = { ...props };      delete pp.onValueChange;      return <div className='settings-ui-input'>        <label htmlFor={props.id}>{ props.label }</label> @@ -26,8 +26,8 @@ class Input extends React.Component<Props> {    }    renderRadio(props: Props) { -    let inputClassName = props.error ? 'input-error' : ''; -    let pp = { ...props }; +    const inputClassName = props.error ? 'input-error' : ''; +    const pp = { ...props };      delete pp.onValueChange;      return <div className='settings-ui-input'>        <label> @@ -41,8 +41,8 @@ class Input extends React.Component<Props> {    }    renderTextArea(props: Props) { -    let inputClassName = props.error ? 'input-error' : ''; -    let pp = { ...props }; +    const inputClassName = props.error ? 'input-error' : ''; +    const pp = { ...props };      delete pp.onValueChange;      return <div className='settings-ui-input'>        <label @@ -57,7 +57,7 @@ class Input extends React.Component<Props> {    }    render() { -    let { type } = this.props; +    const { type } = this.props;      switch (this.props.type) {      case 'text': diff --git a/src/settings/index.tsx b/src/settings/index.tsx index 6aec7a0..cde4488 100644 --- a/src/settings/index.tsx +++ b/src/settings/index.tsx @@ -12,7 +12,7 @@ const store = createStore(  );  document.addEventListener('DOMContentLoaded', () => { -  let wrapper = document.getElementById('vimvixen-settings'); +  const wrapper = document.getElementById('vimvixen-settings');    ReactDOM.render(      <Provider store={store}>        <SettingsComponent store={store} /> diff --git a/src/settings/storage.ts b/src/settings/storage.ts index 2a983df..f375e58 100644 --- a/src/settings/storage.ts +++ b/src/settings/storage.ts @@ -1,7 +1,7 @@  import SettingData, { DefaultSettingData } from '../shared/SettingData';  export const load = async(): Promise<SettingData> => { -  let { settings } = await browser.storage.local.get('settings'); +  const { settings } = await browser.storage.local.get('settings');    if (!settings) {      return DefaultSettingData;    } | 
