Skip to content

Commit f4e3804

Browse files
nstepienamanmahajan7
authored andcommitted
Repo maintenance and cleanups (adazzle#1875)
* rm react-is * Update other deps * rename less files * rm unused markdown dependency * eslint config update and cleanup * Add eslint-plugin-jest
1 parent f7942a6 commit f4e3804

26 files changed

+148
-125
lines changed

.eslintrc.js

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const rules = {
99
'no-await-in-loop': 0,
1010
'no-compare-neg-zero': 2,
1111
'no-cond-assign': 2,
12-
'no-console': 0,
12+
'no-console': 1,
1313
'no-constant-condition': 2,
1414
'no-control-regex': 2,
1515
'no-debugger': 2,
@@ -22,7 +22,7 @@ const rules = {
2222
'no-ex-assign': 2,
2323
'no-extra-boolean-cast': 2,
2424
'no-extra-parens': 0, // replaced by @typescript-eslint/no-extra-parens
25-
'no-extra-semi': 2,
25+
'no-extra-semi': 0, // replaced by @typescript-eslint/no-extra-semi
2626
'no-func-assign': 2,
2727
'no-import-assign': 2,
2828
'no-inner-declarations': 0,
@@ -346,7 +346,7 @@ const rules = {
346346
'react/jsx-curly-newline': 1,
347347
'react/jsx-curly-spacing': 1,
348348
'react/jsx-equals-spacing': 1,
349-
'react/jsx-filename-extension': [1, { extensions: ['.js', '.tsx'] }],
349+
'react/jsx-filename-extension': [1, { extensions: ['.js', '.tsx'] }], // TODO: remove .js
350350
'react/jsx-first-prop-new-line': 1,
351351
'react/jsx-handler-names': 0,
352352
'react/jsx-indent': [1, 2],
@@ -392,6 +392,48 @@ const rules = {
392392
'react-hooks/rules-of-hooks': 2,
393393
'react-hooks/exhaustive-deps': 1,
394394

395+
// https://github.com/jest-community/eslint-plugin-jest#rules
396+
'jest/consistent-test-it': 1,
397+
'jest/expect-expect': 0,
398+
'jest/lowercase-name': 0,
399+
'jest/no-alias-methods': 1,
400+
'jest/no-commented-out-tests': 0, // TODO
401+
'jest/no-disabled-tests': 0,
402+
'jest/no-duplicate-hooks': 2,
403+
'jest/no-expect-resolves': 0,
404+
'jest/no-export': 1,
405+
'jest/no-focused-tests': 1,
406+
'jest/no-hooks': 0, // TODO
407+
'jest/no-identical-title': 2,
408+
'jest/no-if': 1,
409+
'jest/no-jasmine-globals': 1,
410+
'jest/no-jest-import': 1,
411+
'jest/no-large-snapshots': 0,
412+
'jest/no-mocks-import': 1,
413+
'jest/no-standalone-expect': 2,
414+
'jest/no-test-callback': 0,
415+
'jest/no-test-prefixes': 0,
416+
'jest/no-test-return-statement': 0,
417+
'jest/no-truthy-falsy': 1,
418+
'jest/no-try-expect': 1,
419+
'jest/prefer-called-with': 0,
420+
'jest/prefer-expect-assertions': 0,
421+
'jest/prefer-hooks-on-top': 0,
422+
'jest/prefer-inline-snapshots': 0,
423+
'jest/prefer-spy-on': 2,
424+
'jest/prefer-strict-equal': 1,
425+
'jest/prefer-to-be-null': 1,
426+
'jest/prefer-to-be-undefined': 1,
427+
'jest/prefer-to-contain': 1,
428+
'jest/prefer-to-have-length': 1,
429+
'jest/prefer-todo': 1,
430+
'jest/require-top-level-describe': 0,
431+
'jest/require-to-throw-message': 0,
432+
'jest/valid-describe': 2,
433+
'jest/valid-expect-in-promise': 1,
434+
'jest/valid-expect': [1, { alwaysAwait: true }],
435+
'jest/valid-title': 2,
436+
395437
// SonarJS rules
396438
// https://github.com/SonarSource/eslint-plugin-sonarjs#rules
397439
'sonarjs/no-all-duplicated-branches': 2,
@@ -430,7 +472,7 @@ const rules = {
430472
'@typescript-eslint/brace-style': [1, '1tbs', { allowSingleLine: true }],
431473
'@typescript-eslint/camelcase': 0,
432474
'@typescript-eslint/class-name-casing': 0,
433-
'@typescript-eslint/consistent-type-assertions': [2, { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }],
475+
'@typescript-eslint/consistent-type-assertions': [2, { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }], // TODO: allow -> never
434476
'@typescript-eslint/consistent-type-definitions': [1, 'interface'],
435477
'@typescript-eslint/explicit-function-return-type': 0,
436478
'@typescript-eslint/explicit-member-accessibility': 0,
@@ -451,9 +493,11 @@ const rules = {
451493
nestedBinaryExpressions: false,
452494
ignoreJSX: 'all'
453495
}],
496+
'@typescript-eslint/no-extra-semi': 2,
454497
'@typescript-eslint/no-extraneous-class': 2,
455498
'@typescript-eslint/no-floating-promises': 0,
456499
'@typescript-eslint/no-for-in-array': 0,
500+
'@typescript-eslint/no-implied-eval': 0,
457501
'@typescript-eslint/no-inferrable-types': 1,
458502
'@typescript-eslint/no-magic-numbers': 0,
459503
'@typescript-eslint/no-misused-new': 2,
@@ -463,6 +507,7 @@ const rules = {
463507
'@typescript-eslint/no-parameter-properties': 0,
464508
'@typescript-eslint/no-require-imports': 1,
465509
'@typescript-eslint/no-this-alias': 0,
510+
'@typescript-eslint/no-throw-literal': 0,
466511
'@typescript-eslint/no-type-alias': 0,
467512
'@typescript-eslint/no-unnecessary-condition': 0,
468513
'@typescript-eslint/no-unnecessary-qualifier': 0,
@@ -518,22 +563,21 @@ module.exports = {
518563
plugins: [
519564
'react',
520565
'react-hooks',
566+
'jest',
521567
'sonarjs',
522568
'@typescript-eslint'
523569
],
524570
rules,
525571
overrides: [{
572+
// TODO: remove
526573
files: [
527-
'examples/**/*',
528-
'src/**/*'
574+
'examples/**/*'
529575
],
530576
env: {
531577
browser: true
532-
},
533-
globals: {
534-
process: 'readable'
535578
}
536579
}, {
580+
// TODO: remove
537581
files: [
538582
'src/**/__tests__/**/*'
539583
],
@@ -550,8 +594,7 @@ module.exports = {
550594
files: [
551595
'babel.config.js',
552596
'jest.config.js',
553-
'webpack-dev-server.mjs',
554-
'tools/**/*.mjs'
597+
'*.mjs'
555598
],
556599
env: {
557600
node: true
@@ -571,9 +614,6 @@ module.exports = {
571614
],
572615
parserOptions: {
573616
sourceType: 'script'
574-
},
575-
rules: {
576-
'@typescript-eslint/no-require-imports': 0
577617
}
578618
}]
579619
};

examples/demos/example14-all-features-immutable.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ const columns = [
3232
name: 'Title',
3333
editor: <DropDownEditor options={titles} />,
3434
width: 200,
35-
resizable: true,
36-
events: {
37-
onDoubleClick() {
38-
console.log('The user double clicked on title column');
39-
}
40-
}
35+
resizable: true
4136
},
4237
{
4338
key: 'firstName',

examples/demos/example19-column-events.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ export default class extends React.Component {
2020
key: 'title',
2121
name: 'Title',
2222
editor: <DropDownEditor options={titles} />,
23-
resizable: true,
24-
events: {
25-
onDoubleClick(ev, args) {
26-
console.log(`The user entered edit mode on title column with rowIdx: ${args.rowIdx} & rowId: ${args.rowId}`);
27-
}
28-
}
23+
resizable: true
2924
},
3025
{
3126
key: 'name',

package.json

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,36 @@
3636
"postpublish": "git push --follow-tags origin HEAD"
3737
},
3838
"dependencies": {
39-
"@material-ui/core": "^4.7.2",
39+
"@material-ui/core": "^4.8.3",
4040
"@material-ui/icons": "^4.5.1",
41-
"classnames": "^2.2.6",
42-
"react-is": "^16.12.0"
41+
"classnames": "^2.2.6"
4342
},
4443
"devDependencies": {
4544
"@babel/core": "^7.7.7",
4645
"@babel/plugin-proposal-class-properties": "^7.7.4",
4746
"@babel/plugin-transform-runtime": "^7.7.6",
4847
"@babel/preset-env": "^7.7.7",
4948
"@babel/runtime": "^7.7.7",
50-
"@testing-library/react": "^9.3.2",
49+
"@testing-library/react": "^9.4.0",
5150
"@types/classnames": "^2.2.9",
52-
"@types/enzyme": "^3.10.3",
51+
"@types/enzyme": "^3.10.4",
5352
"@types/enzyme-adapter-react-16": "^1.0.5",
5453
"@types/faker": "^4.1.8",
55-
"@types/jest": "^24.0.23",
56-
"@types/react": "^16.9.14",
54+
"@types/jest": "^24.0.25",
55+
"@types/react": "^16.9.17",
5756
"@types/react-dom": "^16.9.4",
58-
"@types/react-is": "^16.7.1",
5957
"@types/react-router-dom": "^5.1.3",
6058
"@types/react-virtualized": "^9.21.7",
61-
"@typescript-eslint/eslint-plugin": "^2.10.0",
62-
"@typescript-eslint/parser": "^2.10.0",
59+
"@typescript-eslint/eslint-plugin": "^2.15.0",
60+
"@typescript-eslint/parser": "^2.15.0",
6361
"babel-loader": "^8.0.6",
6462
"clean-css": "^4.2.1",
6563
"core-js": "^3.6.2",
66-
"css-loader": "^3.2.1",
67-
"enzyme": "^3.10.0",
68-
"enzyme-adapter-react-16": "^1.15.1",
69-
"eslint": "^6.7.2",
64+
"css-loader": "^3.4.1",
65+
"enzyme": "^3.11.0",
66+
"enzyme-adapter-react-16": "^1.15.2",
67+
"eslint": "^6.8.0",
68+
"eslint-plugin-jest": "^23.4.0",
7069
"eslint-plugin-react": "^7.17.0",
7170
"eslint-plugin-react-hooks": "^2.3.0",
7271
"eslint-plugin-sonarjs": "^0.5.0",
@@ -75,20 +74,19 @@
7574
"jest": "^24.9.0",
7675
"less": "^3.10.3",
7776
"less-loader": "^5.0.0",
78-
"markdown": "^0.5.0",
7977
"react": "^16.12.0",
8078
"react-contextmenu": "^2.13.0",
8179
"react-dnd-test-backend": "^2.6.0",
8280
"react-dom": "^16.12.0",
8381
"react-router-dom": "^5.1.2",
8482
"react-virtualized": "^9.21.2",
85-
"recharts": "^1.7.1",
86-
"style-loader": "^1.0.1",
87-
"ts-jest": "^24.2.0",
83+
"recharts": "^1.8.5",
84+
"style-loader": "^1.1.2",
85+
"ts-jest": "^24.3.0",
8886
"ts-loader": "^6.2.1",
89-
"typescript": "~3.7.3",
90-
"webpack": "^4.41.2",
91-
"webpack-dev-server": "^3.9.0"
87+
"typescript": "~3.7.4",
88+
"webpack": "^4.41.5",
89+
"webpack-dev-server": "^3.10.1"
9290
},
9391
"peerDependencies": {
9492
"react": "^16.8",

src/__tests__/Cell.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Cell Tests', () => {
3737
it('should render a SimpleCellFormatter with value', () => {
3838
const wrapper = renderComponent();
3939
const formatter = wrapper.find(SimpleCellFormatter);
40-
expect(formatter.props().row[defaultColumn.key]).toEqual('Wicklow');
40+
expect(formatter.props().row[defaultColumn.key]).toStrictEqual('Wicklow');
4141
});
4242

4343
it('should render a custom formatter when specified on column', () => {
@@ -50,7 +50,7 @@ describe('Cell Tests', () => {
5050

5151
const wrapper = renderComponent({ column });
5252
const formatterInstance = wrapper.find(CustomFormatter);
53-
expect(formatterInstance.prop('row')[column.key]).toEqual('Wicklow');
53+
expect(formatterInstance.prop('row')[column.key]).toStrictEqual('Wicklow');
5454
});
5555

5656
it('should render children when those are passed', () => {
@@ -79,7 +79,7 @@ describe('Cell Tests', () => {
7979
it('passes classname property', () => {
8080
const wrapper = shallowRenderComponent(requiredProperties);
8181
const cellDiv = wrapper.find('div').at(0);
82-
expect(cellDiv.hasClass('rdg-cell'));
82+
expect(cellDiv.hasClass('rdg-cell')).toBe(true);
8383
});
8484
it('passes style property', () => {
8585
const wrapper = shallowRenderComponent(requiredProperties);

src/__tests__/HeaderCell.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ describe('Header Cell Tests', () => {
5959
describe('Render draggableHeaderCell', () => {
6060
it('should not render DraggableHeaderCell when draggable is false', () => {
6161
const { wrapper } = setup({}, { draggable: false });
62-
expect(wrapper.find(DraggableHeaderCell).length).toBe(0);
62+
expect(wrapper.find(DraggableHeaderCell)).toHaveLength(0);
6363
});
6464

6565
it('should not render DraggableHeaderCell when draggable is true', () => {
6666
const { wrapper } = setup({}, { draggable: true });
67-
expect(wrapper.find(DraggableHeaderCell).length).toBe(1);
67+
expect(wrapper.find(DraggableHeaderCell)).toHaveLength(1);
6868
});
6969
});
7070
});

src/__tests__/HeaderRow.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('Header Row Unit Tests', () => {
9494
it('passes classname property', () => {
9595
const wrapper = renderComponent(requiredProps);
9696
const headerRowDiv = wrapper.find('div').at(0);
97-
expect(headerRowDiv.hasClass('rdg-header-row'));
97+
expect(headerRowDiv.hasClass('rdg-header-row')).toBe(true);
9898
});
9999
it('does not pass width if not available from props', () => {
100100
const wrapper = renderComponent(requiredProps);
@@ -104,7 +104,7 @@ describe('Header Row Unit Tests', () => {
104104
it('does pass the height if available from props', () => {
105105
const wrapper = renderComponent(requiredProps);
106106
const headerRowDiv = wrapper.find('div').at(0);
107-
expect(headerRowDiv.props().style).toEqual({ height: 35, width: 1000 });
107+
expect(headerRowDiv.props().style).toStrictEqual({ height: 35, width: 1000 });
108108
});
109109
});
110110
});

src/__tests__/Row.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Row', () => {
3434
it('passes classname property', () => {
3535
const { wrapper } = setup(requiredProperties);
3636
const draggableDiv = wrapper.find('div').at(0);
37-
expect(draggableDiv.hasClass('rdg-row'));
37+
expect(draggableDiv.hasClass('rdg-row')).toBe(true);
3838
});
3939

4040
it('passes style property', () => {

src/editors/__tests__/EditorContainer.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ describe('Editor Container Tests', () => {
8383
const { wrapper } = setup();
8484
const editor = wrapper.find(SimpleTextEditor);
8585

86-
expect(editor.length).toBe(1);
87-
expect(editor.props().value).toEqual('Adwolf');
88-
expect(editor.props().column).toEqual(fakeColumn);
86+
expect(editor).toHaveLength(1);
87+
expect(editor.props().value).toStrictEqual('Adwolf');
88+
expect(editor.props().column).toStrictEqual(fakeColumn);
8989
});
9090

9191
it('should render the editor container div with correct properties', () => {
@@ -124,7 +124,7 @@ describe('Editor Container Tests', () => {
124124
const { wrapper } = innerSetup();
125125
const editor = wrapper.find(TestEditor);
126126

127-
expect(editor.length).toBe(1);
127+
expect(editor).toHaveLength(1);
128128
expect(editor.prop('value')).toBe('SupernaviX');
129129
expect(editor.prop('onCommit')).toBeDefined();
130130
expect(editor.prop('onCommitCancel')).toBeDefined();

src/masks/__tests__/DragMask.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('DragMask', () => {
3636
it('should not render the CellMask component if the drag handle is on the same row as the dragged cell', () => {
3737
const mask = setup({ idx: 0, rowIdx: 2, overRowIdx: 2 });
3838

39-
expect(mask.length).toBe(0);
39+
expect(mask).toHaveLength(0);
4040
});
4141

4242
it('should render the CellMask component with correct position for the dragged down cell', () => {

0 commit comments

Comments
 (0)