Skip to content

Commit 636269a

Browse files
Upgrade test harness (#2170)
1 parent 1fb860e commit 636269a

27 files changed

Lines changed: 1440 additions & 2691 deletions

.eslintrc.js

Lines changed: 32 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,38 @@
1-
const {getESLintConfig, deepMerge} = require('ocular-dev-tools');
1+
const {getESLintConfig} = require('ocular-dev-tools/configuration');
22

3-
const defaultConfig = getESLintConfig({react: '16.8.2'});
3+
module.exports = getESLintConfig({
4+
react: '16.8.2',
5+
overrides: {
6+
parserOptions: {
7+
project: ['./tsconfig.json'],
8+
ecmaVersion: 2020
9+
},
410

5-
// Make any changes to default config here
6-
const config = deepMerge(defaultConfig, {
7-
parserOptions: {
8-
project: ['./tsconfig.json'],
9-
ecmaVersion: 2020
10-
},
11+
rules: {
12+
'max-depth': ['warn', 4],
13+
complexity: ['warn'],
14+
'max-statements': ['warn'],
15+
'callback-return': 0
16+
},
1117

12-
env: {
13-
es2020: true
14-
// browser: true,
15-
// node: true
16-
},
17-
18-
rules: {
19-
camelcase: 0,
20-
indent: 0,
21-
'import/no-unresolved': 0,
22-
'import/no-extraneous-dependencies': 0, // ['warn'],
23-
'no-console': 1,
24-
'no-continue': ['warn'],
25-
'callback-return': 0,
26-
'max-depth': ['warn', 4],
27-
complexity: ['warn'],
28-
'max-statements': ['warn'],
29-
'default-case': ['warn'],
30-
'no-eq-null': ['warn'],
31-
eqeqeq: ['warn'],
32-
radix: 0
33-
// 'accessor-pairs': ['error', {getWithoutSet: false, setWithoutGet: false}]
34-
},
35-
36-
overrides: [
37-
{
38-
files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'],
39-
rules: {
40-
indent: 0,
41-
quotes: ['error', 'single', {avoidEscape: true}],
42-
// For parquet module
43-
'@typescript-eslint/no-non-null-assertion': 0,
44-
'@typescript-eslint/no-non-null-asserted-optional-chain': 0,
45-
// Gradually enable
46-
'@typescript-eslint/ban-ts-comment': 0,
47-
'@typescript-eslint/ban-types': 0,
48-
'@typescript-eslint/no-unsafe-member-access': 0,
49-
'@typescript-eslint/no-unsafe-assignment': 0,
50-
'@typescript-eslint/no-var-requires': 0,
51-
'@typescript-eslint/no-unused-vars': [
52-
'warn',
53-
{vars: 'all', args: 'none', ignoreRestSiblings: false}
54-
],
55-
// We still have some issues with import resolution
56-
'import/named': 0,
57-
// Warn instead of error
58-
// 'max-params': ['warn'],
59-
// 'no-undef': ['warn'],
60-
// camelcase: ['warn'],
61-
// '@typescript-eslint/no-floating-promises': ['warn'],
62-
// '@typescript-eslint/await-thenable': ['warn'],
63-
// '@typescript-eslint/no-misused-promises': ['warn'],
64-
'@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}],
65-
// We use function hoisting
66-
'@typescript-eslint/no-use-before-define': 0,
67-
// We always want explicit typing, e.g `field: string = ''`
68-
'@typescript-eslint/no-inferrable-types': 0,
69-
'@typescript-eslint/restrict-template-expressions': 0,
70-
'@typescript-eslint/explicit-module-boundary-types': 0,
71-
'@typescript-eslint/require-await': 0,
72-
'@typescript-eslint/no-unsafe-return': 0,
73-
'@typescript-eslint/no-unsafe-call': 0,
74-
'@typescript-eslint/no-empty-interface': 0,
75-
'@typescript-eslint/restrict-plus-operands': 0
18+
overrides: [
19+
{
20+
files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'],
21+
rules: {
22+
// Gradually enable
23+
'@typescript-eslint/ban-ts-comment': 0,
24+
'@typescript-eslint/ban-types': 0,
25+
'@typescript-eslint/no-unsafe-member-access': 0,
26+
'@typescript-eslint/no-unsafe-assignment': 0,
27+
'import/named': 0,
28+
'@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}],
29+
'@typescript-eslint/restrict-template-expressions': 0,
30+
'@typescript-eslint/explicit-module-boundary-types': 0,
31+
'@typescript-eslint/no-unsafe-return': 0,
32+
'@typescript-eslint/no-unsafe-call': 0,
33+
'@typescript-eslint/restrict-plus-operands': 0
34+
}
7635
}
77-
}
78-
],
79-
80-
settings: {
81-
// Ensure eslint finds typescript files
82-
'import/resolver': {
83-
node: {
84-
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx']
85-
}
86-
}
36+
]
8737
}
8838
});
89-
90-
module.exports = config;

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Use Node.js
2424
uses: actions/setup-node@v1
2525
with:
26-
node-version: '12.x'
26+
node-version: '16.x'
2727

2828
- name: Publish release
2929
run: |

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
env:
15-
MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}
15+
VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}
1616

1717
steps:
1818
- uses: actions/checkout@v2.1.1
1919

2020
- name: Use Node.js
2121
uses: actions/setup-node@v1
2222
with:
23-
node-version: '14.x'
23+
node-version: '16.x'
2424

2525
- name: Install dependencies
2626
run: |

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Use Node.js
2121
uses: actions/setup-node@v1
2222
with:
23-
node-version: '14.x'
23+
node-version: '16.x'
2424

2525
- name: Get version
2626
id: get-version

.ocularrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const config = {
55
paths: ['src', 'test', 'examples']
66
},
77

8+
typescript: {
9+
project: 'tsconfig.json'
10+
},
11+
812
aliases: {
913
'react-map-gl/test': resolve('./test'),
1014
'react-map-gl': resolve('./src')
@@ -17,7 +21,7 @@ const config = {
1721
entry: {
1822
test: 'test/node.js',
1923
'test-browser': 'test/browser.js',
20-
size: 'test/size/import-nothing.js'
24+
size: ['test/size/all.js', 'test/size/map.js']
2125
}
2226
};
2327

babel.config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
2-
const {getBabelConfig} = require('ocular-dev-tools');
1+
const {getBabelConfig} = require('ocular-dev-tools/configuration');
32

4-
module.exports = api => {
5-
let config = getBabelConfig(api, {react: true});
6-
7-
return config;
8-
};
3+
module.exports = getBabelConfig({
4+
react: true,
5+
overrides: {}
6+
});

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<title>react-map-gl unit tests</title>
66
</head>
77
<body>
8-
<script src='test-browser-bundle.js'></script>
8+
<script src='./test/browser.js'></script>
99
</body>
1010
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"coveralls": "^3.0.0",
5555
"jsdom": "^16.5.0",
5656
"mapbox-gl": "^2.8.0",
57-
"ocular-dev-tools": "beta",
57+
"ocular-dev-tools": "2.0.0-alpha.13",
5858
"pre-commit": "^1.2.2",
5959
"react": "^18.0.0",
6060
"react-dom": "^18.0.0",

test/browser.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
/* global window */
2-
const test = require('tape');
3-
const {_enableDOMLogging: enableDOMLogging} = require('@probe.gl/test-utils');
2+
import test from 'tape';
43

5-
let failed = false;
64
test.onFinish(window.browserTestDriver_finish);
7-
test.onFailure(() => {
8-
failed = true;
9-
window.browserTestDriver_fail();
10-
});
5+
test.onFailure(window.browserTestDriver_fail);
116

12-
// tap-browser-color alternative
13-
enableDOMLogging({
14-
getStyle: message => ({
15-
background: failed ? '#F28E82' : '#8ECA6C',
16-
position: 'absolute',
17-
top: '500px',
18-
width: '100%'
19-
})
20-
});
21-
22-
require('./render');
7+
import './render';

test/node.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
const register = require('@babel/register').default;
2-
const path = require('path');
31
const {JSDOM} = require('jsdom');
42

5-
const moduleAlias = require('module-alias');
6-
moduleAlias.addAliases({
7-
'mapbox-gl': path.resolve(__dirname, './src/utils/mapbox-gl-mock')
8-
});
9-
10-
register({extensions: ['.ts', '.tsx', '.js']});
11-
123
const dom = new JSDOM(`<!DOCTYPE html><div id="map"></div>`);
134
/* global global */
145
global.document = dom.window.document;

0 commit comments

Comments
 (0)