diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/background/components/operation.js | 2 | ||||
-rw-r--r-- | src/background/reducers/find.js | 5 | ||||
-rw-r--r-- | src/background/reducers/index.js | 5 | ||||
-rw-r--r-- | src/background/reducers/setting.js | 6 | ||||
-rw-r--r-- | src/console/reducers/index.js | 51 | ||||
-rw-r--r-- | src/content/actions/operation.js | 2 | ||||
-rw-r--r-- | src/content/actions/setting.js | 7 | ||||
-rw-r--r-- | src/content/reducers/addon.js | 15 | ||||
-rw-r--r-- | src/content/reducers/find.js | 5 | ||||
-rw-r--r-- | src/content/reducers/follow-controller.js | 20 | ||||
-rw-r--r-- | src/content/reducers/index.js | 5 | ||||
-rw-r--r-- | src/content/reducers/input.js | 10 | ||||
-rw-r--r-- | src/content/reducers/setting.js | 2 | ||||
-rw-r--r-- | src/settings/components/form/keymaps-form.jsx | 2 | ||||
-rw-r--r-- | src/settings/components/form/properties-form.jsx | 2 | ||||
-rw-r--r-- | src/settings/components/form/search-form.jsx | 4 | ||||
-rw-r--r-- | src/settings/components/index.jsx | 16 | ||||
-rw-r--r-- | src/shared/settings/storage.js | 6 | ||||
-rw-r--r-- | src/shared/settings/values.js | 6 |
19 files changed, 73 insertions, 98 deletions
diff --git a/src/background/components/operation.js b/src/background/components/operation.js index 58edb8c..465baf0 100644 --- a/src/background/components/operation.js +++ b/src/background/components/operation.js @@ -28,7 +28,7 @@ export default class BackgroundComponent { } } - // eslint-disable-next-line complexity + // eslint-disable-next-line complexity, max-lines-per-function exec(operation, tab) { let tabState = this.store.getState().tab; diff --git a/src/background/reducers/find.js b/src/background/reducers/find.js index 4ded801..bbc6b36 100644 --- a/src/background/reducers/find.js +++ b/src/background/reducers/find.js @@ -7,9 +7,8 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.FIND_SET_KEYWORD: - return Object.assign({}, state, { - keyword: action.keyword, - }); + return { ...state, + keyword: action.keyword, }; default: return state; } diff --git a/src/background/reducers/index.js b/src/background/reducers/index.js index 5729f0a..78f855c 100644 --- a/src/background/reducers/index.js +++ b/src/background/reducers/index.js @@ -10,9 +10,8 @@ const defaultState = { }; export default function reducer(state = defaultState, action = {}) { - return Object.assign({}, state, { + return { ...state, setting: settingReducer(state.setting, action), find: findReducer(state.find, action), - tab: tabReducer(state.tab, action), - }); + tab: tabReducer(state.tab, action), }; } diff --git a/src/background/reducers/setting.js b/src/background/reducers/setting.js index 045a654..8dbc1b4 100644 --- a/src/background/reducers/setting.js +++ b/src/background/reducers/setting.js @@ -12,10 +12,8 @@ export default function reducer(state = defaultState, action = {}) { }; case actions.SETTING_SET_PROPERTY: return { - value: Object.assign({}, state.value, { - properties: Object.assign({}, state.value.properties, - { [action.name]: action.value }) - }) + value: { ...state.value, + properties: { ...state.value.properties, [action.name]: action.value }} }; default: return state; diff --git a/src/console/reducers/index.js b/src/console/reducers/index.js index 2aec55c..71b0776 100644 --- a/src/console/reducers/index.js +++ b/src/console/reducers/index.js @@ -51,68 +51,61 @@ const nextConsoleText = (completions, group, item, defaults) => { return completions[group].items[item].content; }; +// eslint-disable-next-line max-lines-per-function export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.CONSOLE_HIDE: - return Object.assign({}, state, { - mode: '', - }); + return { ...state, + mode: '', }; case actions.CONSOLE_SHOW_COMMAND: - return Object.assign({}, state, { + return { ...state, mode: 'command', consoleText: action.text, - completions: [] - }); + completions: []}; case actions.CONSOLE_SHOW_FIND: - return Object.assign({}, state, { + return { ...state, mode: 'find', consoleText: '', - completions: [] - }); + completions: []}; case actions.CONSOLE_SHOW_ERROR: - return Object.assign({}, state, { + return { ...state, mode: 'error', - messageText: action.text, - }); + messageText: action.text, }; case actions.CONSOLE_SHOW_INFO: - return Object.assign({}, state, { + return { ...state, mode: 'info', - messageText: action.text, - }); + messageText: action.text, }; case actions.CONSOLE_HIDE_COMMAND: - return Object.assign({}, state, { + return { + ...state, mode: state.mode === 'command' || state.mode === 'find' ? '' : state.mode, - }); + }; case actions.CONSOLE_SET_CONSOLE_TEXT: - return Object.assign({}, state, { - consoleText: action.consoleText, - }); + return { ...state, + consoleText: action.consoleText, }; case actions.CONSOLE_SET_COMPLETIONS: - return Object.assign({}, state, { + return { ...state, completions: action.completions, completionSource: action.completionSource, groupSelection: -1, - itemSelection: -1, - }); + itemSelection: -1, }; case actions.CONSOLE_COMPLETION_NEXT: { let next = nextSelection(state); - return Object.assign({}, state, { + return { ...state, groupSelection: next[0], itemSelection: next[1], consoleText: nextConsoleText( state.completions, next[0], next[1], - state.completionSource), - }); + state.completionSource), }; } case actions.CONSOLE_COMPLETION_PREV: { let next = prevSelection(state); - return Object.assign({}, state, { + return { ...state, groupSelection: next[0], itemSelection: next[1], consoleText: nextConsoleText( state.completions, next[0], next[1], - state.completionSource), - }); + state.completionSource), }; } default: return state; diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js index 9171766..40ac52d 100644 --- a/src/content/actions/operation.js +++ b/src/content/actions/operation.js @@ -8,7 +8,7 @@ import * as consoleFrames from 'content/console-frames'; import * as addonActions from './addon'; import * as properties from 'shared/settings/properties'; -// eslint-disable-next-line complexity +// eslint-disable-next-line complexity, max-lines-per-function const exec = (operation, repeat, settings) => { let smoothscroll = settings.properties.smoothscroll || properties.defaults.smoothscroll; diff --git a/src/content/actions/setting.js b/src/content/actions/setting.js index 4c1e385..e34b6e0 100644 --- a/src/content/actions/setting.js +++ b/src/content/actions/setting.js @@ -10,7 +10,7 @@ const reservedKeymaps = { const set = (value) => { let entries = []; if (value.keymaps) { - let keymaps = Object.assign({}, value.keymaps, reservedKeymaps); + let keymaps = { ...value.keymaps, ...reservedKeymaps }; entries = Object.entries(keymaps).map((entry) => { return [ keyUtils.fromMapKeys(entry[0]), @@ -21,9 +21,8 @@ const set = (value) => { return { type: actions.SETTING_SET, - value: Object.assign({}, value, { - keymaps: entries, - }) + value: { ...value, + keymaps: entries, } }; }; diff --git a/src/content/reducers/addon.js b/src/content/reducers/addon.js index 8cc5ef1..b881ca0 100644 --- a/src/content/reducers/addon.js +++ b/src/content/reducers/addon.js @@ -7,17 +7,14 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.ADDON_ENABLE: - return Object.assign({}, state, { - enabled: true, - }); + return { ...state, + enabled: true, }; case actions.ADDON_DISABLE: - return Object.assign({}, state, { - enabled: false, - }); + return { ...state, + enabled: false, }; case actions.ADDON_TOGGLE_ENABLED: - return Object.assign({}, state, { - enabled: !state.enabled, - }); + return { ...state, + enabled: !state.enabled, }; default: return state; } diff --git a/src/content/reducers/find.js b/src/content/reducers/find.js index 8d63ee5..4560e2c 100644 --- a/src/content/reducers/find.js +++ b/src/content/reducers/find.js @@ -8,10 +8,9 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.FIND_SET_KEYWORD: - return Object.assign({}, state, { + return { ...state, keyword: action.keyword, - found: action.found, - }); + found: action.found, }; default: return state; } diff --git a/src/content/reducers/follow-controller.js b/src/content/reducers/follow-controller.js index 78fd848..5869c47 100644 --- a/src/content/reducers/follow-controller.js +++ b/src/content/reducers/follow-controller.js @@ -10,24 +10,20 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.FOLLOW_CONTROLLER_ENABLE: - return Object.assign({}, state, { + return { ...state, enabled: true, newTab: action.newTab, background: action.background, - keys: '', - }); + keys: '', }; case actions.FOLLOW_CONTROLLER_DISABLE: - return Object.assign({}, state, { - enabled: false, - }); + return { ...state, + enabled: false, }; case actions.FOLLOW_CONTROLLER_KEY_PRESS: - return Object.assign({}, state, { - keys: state.keys + action.key, - }); + return { ...state, + keys: state.keys + action.key, }; case actions.FOLLOW_CONTROLLER_BACKSPACE: - return Object.assign({}, state, { - keys: state.keys.slice(0, -1), - }); + return { ...state, + keys: state.keys.slice(0, -1), }; default: return state; } diff --git a/src/content/reducers/index.js b/src/content/reducers/index.js index 2487d85..c3a474e 100644 --- a/src/content/reducers/index.js +++ b/src/content/reducers/index.js @@ -14,11 +14,12 @@ const defaultState = { }; export default function reducer(state = defaultState, action = {}) { - return Object.assign({}, state, { + return { + ...state, addon: addonReducer(state.addon, action), find: findReducer(state.find, action), setting: settingReducer(state.setting, action), input: inputReducer(state.input, action), followController: followControllerReducer(state.followController, action), - }); + }; } diff --git a/src/content/reducers/input.js b/src/content/reducers/input.js index 134aa95..23e7dd2 100644 --- a/src/content/reducers/input.js +++ b/src/content/reducers/input.js @@ -7,13 +7,11 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.INPUT_KEY_PRESS: - return Object.assign({}, state, { - keys: state.keys.concat([action.key]), - }); + return { ...state, + keys: state.keys.concat([action.key]), }; case actions.INPUT_CLEAR_KEYS: - return Object.assign({}, state, { - keys: [], - }); + return { ...state, + keys: [], }; default: return state; } diff --git a/src/content/reducers/setting.js b/src/content/reducers/setting.js index a23027f..a49db6d 100644 --- a/src/content/reducers/setting.js +++ b/src/content/reducers/setting.js @@ -8,7 +8,7 @@ const defaultState = { export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.SETTING_SET: - return Object.assign({}, action.value); + return { ...action.value }; default: return state; } diff --git a/src/settings/components/form/keymaps-form.jsx b/src/settings/components/form/keymaps-form.jsx index f0f69cf..dcf65d9 100644 --- a/src/settings/components/form/keymaps-form.jsx +++ b/src/settings/components/form/keymaps-form.jsx @@ -100,7 +100,7 @@ class KeymapsForm extends Component { return; } - let next = Object.assign({}, this.props.value); + let next = { ...this.props.value }; next[e.target.name] = e.target.value; this.props.onChange(next); diff --git a/src/settings/components/form/properties-form.jsx b/src/settings/components/form/properties-form.jsx index 55c8512..ceb79d7 100644 --- a/src/settings/components/form/properties-form.jsx +++ b/src/settings/components/form/properties-form.jsx @@ -44,7 +44,7 @@ class PropertiesForm extends Component { } let name = e.target.name; - let next = Object.assign({}, this.props.value); + let 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/search-form.jsx b/src/settings/components/form/search-form.jsx index e85761f..2d5f01b 100644 --- a/src/settings/components/form/search-form.jsx +++ b/src/settings/components/form/search-form.jsx @@ -53,10 +53,10 @@ class SearchForm extends Component { let value = this.props.value; let name = e.target.name; let index = e.target.getAttribute('data-index'); - let next = Object.assign({}, { + let next = { default: value.default, engines: value.engines ? value.engines.slice() : [], - }); + }; if (name === 'name') { next.engines[index][0] = e.target.value; diff --git a/src/settings/components/index.jsx b/src/settings/components/index.jsx index e13bfa1..c479986 100644 --- a/src/settings/components/index.jsx +++ b/src/settings/components/index.jsx @@ -134,7 +134,7 @@ class SettingsComponent extends Component { } validateValue(e) { - let next = Object.assign({}, this.state); + let next = { ...this.state }; next.errors.json = ''; try { @@ -146,18 +146,16 @@ class SettingsComponent extends Component { } bindForm(name, value) { - let next = Object.assign({}, this.state, { - settings: Object.assign({}, this.state.settings, { - form: Object.assign({}, this.state.settings.form) - }) - }); + let next = { ...this.state, + settings: { ...this.state.settings, + form: { ...this.state.settings.form }}}; next.settings.form[name] = value; this.setState(next); this.context.store.dispatch(settingActions.save(next.settings)); } bindValue(e) { - let next = Object.assign({}, this.state); + let next = { ...this.state }; let error = false; next.errors.json = ''; @@ -190,7 +188,7 @@ class SettingsComponent extends Component { let form = settingsValues.formFromJson( this.state.settings.json, KeymapsForm.AllowdOps); - let next = Object.assign({}, this.state); + let next = { ...this.state }; next.settings.form = form; next.settings.source = 'form'; next.errors.json = ''; @@ -201,7 +199,7 @@ class SettingsComponent extends Component { migrateToJson() { let json = settingsValues.jsonFromForm(this.state.settings.form); - let next = Object.assign({}, this.state); + let next = { ...this.state }; next.settings.json = json; next.settings.source = 'json'; next.errors.json = ''; diff --git a/src/shared/settings/storage.js b/src/shared/settings/storage.js index 87843ed..5dce3b0 100644 --- a/src/shared/settings/storage.js +++ b/src/shared/settings/storage.js @@ -6,7 +6,7 @@ const loadRaw = async() => { if (!settings) { return DefaultSettings; } - return Object.assign({}, DefaultSettings, settings); + return { ...DefaultSettings, ...settings }; }; const loadValue = async() => { @@ -20,9 +20,7 @@ const loadValue = async() => { if (!value.properties) { value.properties = {}; } - return Object.assign({}, - settingsValues.valueFromJson(DefaultSettings.json), - value); + return { ...settingsValues.valueFromJson(DefaultSettings.json), ...value }; }; const save = (settings) => { diff --git a/src/shared/settings/values.js b/src/shared/settings/values.js index bd03be2..9828af6 100644 --- a/src/shared/settings/values.js +++ b/src/shared/settings/values.js @@ -6,12 +6,12 @@ const operationFromFormName = (name) => { if (argStr) { args = JSON.parse(argStr); } - return Object.assign({ type }, args); + return { type, ...args }; }; const operationToFormName = (op) => { let type = op.type; - let args = Object.assign({}, op); + let args = { ...op }; delete args.type; if (Object.keys(args).length === 0) { @@ -83,7 +83,7 @@ const formFromValue = (value, allowedOps) => { } } - let formProperties = Object.assign({}, properties.defaults, value.properties); + let formProperties = { ...properties.defaults, ...value.properties }; return { keymaps, |