Skip to content

Commit cf45b64

Browse files
authored
Configure eslint for spec files (#1564)
* Added eslint-plugin-jasmine and eslint-plugin-jest * Fix eslint-plugin-jest errors * Remove duplicated tests
1 parent 348fff0 commit cf45b64

31 files changed

Lines changed: 143 additions & 130 deletions

.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module.exports = {
66
'@typescript-eslint',
77
'license-header',
88
'jsdoc',
9+
'jasmine',
10+
'jest',
911
],
12+
env: {
13+
jasmine: true,
14+
'jest/globals': true,
15+
},
1016
parserOptions: {
1117
tsconfigRootDir: __dirname,
1218
project: './tsconfig.test.json',
@@ -17,6 +23,9 @@ module.exports = {
1723
'plugin:@typescript-eslint/eslint-recommended',
1824
'plugin:@typescript-eslint/recommended',
1925
'plugin:@typescript-eslint/recommended-requiring-type-checking',
26+
'plugin:jasmine/recommended',
27+
'plugin:jest/recommended',
28+
'plugin:jest/style',
2029
],
2130
rules: {
2231
// Automatic fixers
@@ -113,6 +122,13 @@ module.exports = {
113122
MethodDefinition: true,
114123
}
115124
}],
125+
'jest/no-jasmine-globals': 'off',
126+
'jest/no-alias-methods': 'off',
127+
'jest/no-conditional-expect': 'warn',
128+
'jest/no-standalone-expect': 'warn',
129+
'jest/no-test-prefixes': 'off',
130+
'jest/prefer-to-be': 'warn',
131+
'jest/prefer-to-have-length': 'warn',
116132
},
117133
overrides: [
118134
{

package-lock.json

Lines changed: 67 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
"env-cmd": "^10.1.0",
134134
"eslint": "^8.57.1",
135135
"eslint-config-prettier": "^9.1.0",
136+
"eslint-plugin-jasmine": "^4.2.2",
137+
"eslint-plugin-jest": "^27.9.0",
136138
"eslint-plugin-jsdoc": "^50.5.0",
137139
"eslint-plugin-license-header": "^0.6.1",
138140
"eslint-plugin-prettier": "^5.2.1",

test/unit/AbsoluteCellRange.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ describe('AbsoluteCellRange', () => {
77
it('true in simplest case', () => {
88
const range = AbsoluteCellRange.fromCoordinates(0, 0, 0, 0, 0)
99

10-
expect(range.addressInRange(adr('A1')))
10+
expect(range.addressInRange(adr('A1'))).toBe(true)
1111
})
1212

1313
it('false if different sheets', () => {
1414
const range = AbsoluteCellRange.fromCoordinates(1, 0, 0, 0, 0)
1515

16-
expect(range.addressInRange(adr('A1')))
16+
expect(range.addressInRange(adr('A1'))).toBe(false)
1717
})
1818
})
1919

test/unit/_setupFiles/jest/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {toEqualError} from './toEqualError'
33
beforeAll(() => {
44
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
// @ts-ignore
6+
// eslint-disable-next-line no-global-assign
67
spyOn = jest.spyOn
78
expect.extend(toEqualError)
89
})

test/unit/arrays.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ describe('build from array', () => {
380380
[undefined, ArrayVertex, ArrayVertex],
381381
])
382382
expect(engine.arrayMapping.arrayMapping.size).toEqual(4)
383-
expect(engine.getSheetValues(0))
384383
})
385384

386385
it('should REF last array', () => {
@@ -399,7 +398,6 @@ describe('build from array', () => {
399398
[noSpace(), 2, 2, 1, 2],
400399
])
401400
expect(engine.arrayMapping.arrayMapping.size).toEqual(3)
402-
expect(engine.getSheetValues(0))
403401
})
404402

405403
it('array should work with different types of data', () => {
@@ -490,15 +488,6 @@ describe('column ranges', () => {
490488
expect(engine.getCellValue(adr('A2'))).toEqualError(detailedError(ErrorType.SPILL, ErrorMessage.NoSpaceForArrayResult))
491489
})
492490

493-
it('arithmetic should work for row range', () => {
494-
const engine = HyperFormula.buildFromArray([
495-
['=2*(2:2)', null],
496-
[1, 2],
497-
], {useArrayArithmetic: true})
498-
499-
expect(engine.getSheetValues(0)).toEqual([[2, 4], [1, 2]])
500-
})
501-
502491
it('arithmetic for shifted row range -- error', () => {
503492
const engine = HyperFormula.buildFromArray([
504493
[null, '=2*(2:2)'],

test/unit/column-index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ describe('ColumnIndex#removeColumns', () => {
296296
expect(index.getValueIndex(0, 0, 1).index).toEqual([])
297297
})
298298

299-
it('should remove multiple columns in the middle ', () => {
299+
it('should remove multiple columns in the middle', () => {
300300
const index = buildEmptyIndex(transformingService, new Config(), statistics)
301301
index.add(1, adr('A1'))
302302
index.add(2, adr('B1'))
@@ -311,7 +311,7 @@ describe('ColumnIndex#removeColumns', () => {
311311
expect(index.getValueIndex(0, 3, 4).index).toEqual([])
312312
})
313313

314-
it('should remove columns only in one sheet ', () => {
314+
it('should remove columns only in one sheet', () => {
315315
const index = buildEmptyIndex(transformingService, new Config(), statistics)
316316
index.add(1, adr('A1', 0))
317317
index.add(1, adr('A1', 1))
@@ -455,7 +455,7 @@ describe('ColumnIndex#removeRows', () => {
455455
expect(index.getValueIndex(0, 0, 1).index).toEqual([])
456456
})
457457

458-
it('should remove rows in the middle ', () => {
458+
it('should remove rows in the middle', () => {
459459
const statistics = new Statistics()
460460
const transformingService = new LazilyTransformingAstService(statistics)
461461
const index = buildEmptyIndex(transformingService, new Config(), statistics)

test/unit/cruds/adding-columns-dependencies.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ describe('Adding column, fixing ranges', () => {
316316
]))
317317
})
318318

319-
it('it should insert new cell with edge to only one range at right', () => {
319+
it('should insert new cell with edge to only one range at right', () => {
320320
const engine = HyperFormula.buildFromArray([
321321
['1', '2', /* */ '3', '4'],
322322
['=SUM(A1:A1)', '=SUM(A1:B1)', /* */ '=SUM(A1:C1)', '=SUM(A1:D1)'],

test/unit/cruds/adding-row-dependencies.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ describe('Adding row, ranges', () => {
332332
]))
333333
})
334334

335-
it('it should insert new cell with edge to all ranges below', () => {
335+
it('should insert new cell with edge to all ranges below', () => {
336336
const engine = HyperFormula.buildFromArray([
337337
['1', '=SUM(A1:A1)'],
338338
['2', '=SUM(A1:A2)'],
@@ -358,7 +358,7 @@ describe('Adding row, ranges', () => {
358358
expect(engine.graph.adjacentNodesCount(a2)).toBe(1)
359359
})
360360

361-
it('it should insert new cell with edge to only one range below, shifted by 1', () => {
361+
it('should insert new cell with edge to only one range below, shifted by 1', () => {
362362
const engine = HyperFormula.buildFromArray([
363363
['1', null],
364364
['2', '=SUM(A1:A1)'],

test/unit/cruds/change-cell-content.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ describe('changing cell content', () => {
296296
expect(engine.getCellValue(adr('B1'))).toBe(42)
297297
})
298298

299-
it('set nothing again', () => {
299+
it('set nothing again (2)', () => {
300300
const sheet = [
301301
[null],
302302
]
@@ -486,15 +486,15 @@ describe('changing cell content', () => {
486486
expectArrayWithSameContent(changes.map((change) => change.newValue), [2, 10, 12, 18, 22])
487487
})
488488

489-
it('update empty cell to parsing error ', () => {
489+
it('update empty cell to parsing error', () => {
490490
const engine = HyperFormula.buildFromArray([])
491491

492492
engine.setCellContents(adr('A1'), '=SUM(')
493493

494494
expect(engine.getCellValue(adr('A1'))).toEqualError(detailedError(ErrorType.ERROR, ErrorMessage.ParseError))
495495
})
496496

497-
it('update dependency value cell to parsing error ', () => {
497+
it('update dependency value cell to parsing error', () => {
498498
const sheet = [
499499
['1', '=SUM(A1)'],
500500
]
@@ -509,7 +509,7 @@ describe('changing cell content', () => {
509509
expect(engine.getCellValue(adr('B1'))).toEqualError(detailedError(ErrorType.ERROR, ErrorMessage.ParseError))
510510
})
511511

512-
it('update formula cell to parsing error ', () => {
512+
it('update formula cell to parsing error', () => {
513513
const sheet = [
514514
['1', '=SUM(A1)'],
515515
]
@@ -907,7 +907,6 @@ describe('arrays', () => {
907907
[undefined, ArrayVertex, ArrayVertex],
908908
])
909909
expect(engine.arrayMapping.arrayMapping.size).toEqual(4)
910-
expect(engine.getSheetValues(0))
911910
})
912911

913912
it('should REF last array', () => {
@@ -931,7 +930,6 @@ describe('arrays', () => {
931930
[noSpace(), 2, 2, 1, 2],
932931
])
933932
expect(engine.arrayMapping.arrayMapping.size).toEqual(3)
934-
expect(engine.getSheetValues(0))
935933
})
936934

937935
it('should make existing array REF and change cell content to simple value', () => {

0 commit comments

Comments
 (0)