fix but failed

jh-changes
Shin'ya Ueoka 6 years ago
parent 03cf265eff
commit e2fb33bdc5
  1. 1
      .eslintrc
  2. 2
      src/background/components/operation.js
  3. 5
      src/background/reducers/find.js
  4. 5
      src/background/reducers/index.js
  5. 6
      src/background/reducers/setting.js
  6. 51
      src/console/reducers/index.js
  7. 2
      src/content/actions/operation.js
  8. 7
      src/content/actions/setting.js
  9. 15
      src/content/reducers/addon.js
  10. 5
      src/content/reducers/find.js
  11. 20
      src/content/reducers/follow-controller.js
  12. 5
      src/content/reducers/index.js
  13. 10
      src/content/reducers/input.js
  14. 2
      src/content/reducers/setting.js
  15. 2
      src/settings/components/form/keymaps-form.jsx
  16. 2
      src/settings/components/form/properties-form.jsx
  17. 4
      src/settings/components/form/search-form.jsx
  18. 16
      src/settings/components/index.jsx
  19. 6
      src/shared/settings/storage.js
  20. 6
      src/shared/settings/values.js

@ -29,6 +29,7 @@
"id-length": "off",
"indent": ["error", 2],
"jsx-quotes": ["error", "prefer-single"],
"max-classes-per-file": "off",
"max-params": ["error", 5],
"max-statements": ["error", 15],
"multiline-comment-style": "off",

@ -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;

@ -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;
}

@ -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), };
}

@ -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;

@ -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;

@ -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;

@ -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, }
};
};

@ -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;
}

@ -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;
}

@ -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;
}

@ -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),
});
};
}

@ -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;
}

@ -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;
}

@ -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);

@ -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') {

@ -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;

@ -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 = '';

@ -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) => {

@ -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,