Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint prefer-object-spread #9466

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ module.exports = {
'no-unused-vars': 0,
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-object-spread': 1,
'prefer-template': 0,
'react/forbid-prop-types': 0,
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('AlteredSliceTag', () => {
let props;

beforeEach(() => {
props = Object.assign({}, defaultProps);
props = { ...defaultProps };
wrapper = shallow(<AlteredSliceTag {...props} />);
});

Expand All @@ -140,8 +140,8 @@ describe('AlteredSliceTag', () => {

it('sets new diffs when receiving new props', () => {
const newProps = {
currentFormData: Object.assign({}, props.currentFormData),
origFormData: Object.assign({}, props.origFormData),
currentFormData: { ...props.currentFormData },
origFormData: { ...props.origFormData },
};
newProps.currentFormData.beta = 10;
wrapper = shallow(<AlteredSliceTag {...props} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Checkbox', () => {

let wrapper;
const factory = o => {
const props = Object.assign({}, defaultProps, o);
const props = { ...defaultProps, ...o };
return shallow(<Checkbox {...props} />);
};
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('ColumnOption', () => {
const factory = o => <ColumnOption {...o} />;
beforeEach(() => {
wrapper = shallow(factory(defaultProps));
props = Object.assign({}, defaultProps);
props = { ...defaultProps };
});
it('is a valid element', () => {
expect(React.isValidElement(<ColumnOption {...defaultProps} />)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('MetricOption', () => {
const factory = o => <MetricOption {...o} />;
beforeEach(() => {
wrapper = shallow(factory(defaultProps));
props = Object.assign({}, defaultProps);
props = { ...defaultProps };
});
it('is a valid element', () => {
expect(React.isValidElement(<MetricOption {...defaultProps} />)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ describe('OnPasteSelect', () => {
let evt;
let expected;
beforeEach(() => {
props = Object.assign({}, defaultProps);
props = { ...defaultProps };
wrapper = shallow(<OnPasteSelect {...props} />);
evt = Object.assign({}, defaultEvt);
evt = { ...defaultEvt };
});

it('renders the supplied selectWrap component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('OptionDescription', () => {
let props;

beforeEach(() => {
props = { option: Object.assign({}, defaultProps.option) };
props = { option: { ...defaultProps.option } };
wrapper = shallow(<OptionDescription {...props} />);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('PopoverSection', () => {

let wrapper;
const factory = overrideProps => {
const props = Object.assign({}, defaultProps, overrideProps || {});
const props = { ...defaultProps, ...(overrideProps || {}) };
return shallow(<PopoverSection {...props} />);
};
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('VirtualizedRendererWrap', () => {
let props;
beforeEach(() => {
wrapper = shallow(<RendererWrap {...defaultProps} />);
props = Object.assign({}, defaultProps);
props = { ...defaultProps };
});

it('uses the provided renderer', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('SelectControl', () => {
});

it('renders a AceEditor when language is specified', () => {
const props = Object.assign({}, defaultProps);
const props = { ...defaultProps };
props.language = 'markdown';
wrapper = shallow(<TextAreaControl {...props} />);
expect(wrapper.find(FormControl)).toHaveLength(0);
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/spec/javascripts/profile/fixtures.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ export const user = {
database_access: ['db1', 'db2', 'db3'],
},
};
export const userNoPerms = Object.assign({}, user, { permissions: {} });
export const userNoPerms = { ...user, permissions: {} };
17 changes: 6 additions & 11 deletions superset-frontend/spec/javascripts/sqllab/ResultSet_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ describe('ResultSet', () => {
query: queries[0],
height: 0,
};
const stoppedQueryProps = Object.assign({}, mockedProps, {
query: stoppedQuery,
});
const runningQueryProps = Object.assign({}, mockedProps, {
query: runningQuery,
});
const cachedQueryProps = Object.assign({}, mockedProps, {
query: cachedQuery,
});
const stoppedQueryProps = { ...mockedProps, query: stoppedQuery };
const runningQueryProps = { ...mockedProps, query: runningQuery };
const cachedQueryProps = { ...mockedProps, query: cachedQuery };
const newProps = {
query: {
cached: false,
Expand Down Expand Up @@ -94,11 +88,12 @@ describe('ResultSet', () => {
});
it('should render empty results', () => {
const wrapper = shallow(<ResultSet {...mockedProps} />);
const emptyResults = Object.assign({}, queries[0], {
const emptyResults = {
...queries[0],
results: {
data: [],
},
});
};
wrapper.setProps({ query: emptyResults });
expect(wrapper.find(FilterableTable)).toHaveLength(0);
expect(wrapper.find(Alert)).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ describe('TabbedSqlEditors', () => {
const tabHistory = ['dfsadfs', 'newEditorId'];

const tables = [
Object.assign({}, table, {
dataPreviewQueryId: 'B1-VQU1zW',
queryEditorId: 'newEditorId',
}),
{ ...table, dataPreviewQueryId: 'B1-VQU1zW', queryEditorId: 'newEditorId' },
];

const queryEditors = [
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/spec/javascripts/sqllab/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sinon from 'sinon';
import * as actions from '../../../src/SqlLab/actions/sqlLab';

export const mockedActions = sinon.stub(Object.assign({}, actions));
export const mockedActions = sinon.stub({ ...actions });

export const alert = { bsStyle: 'danger', msg: 'Ooops', id: 'lksvmcx32' };
export const table = {
Expand Down Expand Up @@ -388,7 +388,7 @@ export const runningQuery = {
state: 'running',
startDttm: Date.now() - 500,
};
export const cachedQuery = Object.assign({}, queries[0], { cached: true });
export const cachedQuery = { ...queries[0], cached: true };

export const initialState = {
sqlLab: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('sqlLabReducer', () => {
let newState;
let newTable;
beforeEach(() => {
newTable = Object.assign({}, table);
newTable = { ...table };
const action = {
type: actions.MERGE_TABLE,
table: newTable,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/QueryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class QueryTable extends React.PureComponent {
render() {
const data = this.props.queries
.map(query => {
const q = Object.assign({}, query);
const q = { ...query };
if (q.endDttm) {
q.duration = fDuration(q.startDttm, q.endDttm);
}
Expand Down
Loading