Skip to content

Commit

Permalink
Upgrade dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Aug 28, 2024
1 parent 6222374 commit a7ba6ff
Show file tree
Hide file tree
Showing 52 changed files with 15,649 additions and 14,021 deletions.
53 changes: 11 additions & 42 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,84 +1,53 @@
const {getESLintConfig} = require('ocular-dev-tools/configuration');
const {getESLintConfig} = require('@vis.gl/dev-tools/configuration');

module.exports = getESLintConfig({
react: '16.8.2',
overrides: {
parser: '',
parserOptions: {
project: ['./tsconfig.json']
},

env: {
browser: true,
es2020: true,
node: true
},

rules: {
'import/no-unresolved': 1,
'no-console': 1,
'no-console': 'warn',
'no-continue': ['warn'],
'callback-return': 0,
'accessor-pairs': 0,
'max-depth': ['warn', 4],
camelcase: 'off',
complexity: 'off',
'max-statements': 'off',
'default-case': ['warn'],
'no-eq-null': ['warn'],
eqeqeq: ['warn'],
radix: 0
// 'accessor-pairs': ['error', {getWithoutSet: false, setWithoutGet: false}]
complexity: 'warn',
'max-statements': 'warn'
},

overrides: [
{
files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'],
rules: {

'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-use-before-define': 'off',

'@typescript-eslint/no-floating-promises': 0,
// Gradually enable
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-unused-vars': [
'warn',
{vars: 'all', args: 'none', ignoreRestSiblings: false}
],
// We still have some issues with import resolution
'import/named': 0,
'import/no-extraneous-dependencies': ['error', {devDependencies: true}], // Warn instead of error
// 'max-params': ['warn'],
// 'no-undef': ['warn'],
// camelcase: ['warn'],
// '@typescript-eslint/no-floating-promises': ['warn'],
// '@typescript-eslint/await-thenable': ['warn'],
// '@typescript-eslint/no-misused-promises': ['warn'],
'@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}],
// We use function hoisting
'@typescript-eslint/no-use-before-define': 0,
// We always want explicit typing, e.g `field: string = ''`
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/restrict-template-expressions': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/require-await': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/restrict-plus-operands': 0
}
},
{
// scripts use devDependencies
files: ['*worker*.js', '**/worker-utils/**/*.js'],
env: {
browser: true,
es2020: true,
node: true,
worker: true
}
},
// tests are run with aliases set up in node and webpack.
// This means lint will not find the imported files and generate false warnings
{
Expand Down
32 changes: 14 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,35 @@ name: test
on:
push:
branches:
- master
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]

steps:
- uses: actions/[email protected]

- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
with:
node-version: ${{ matrix.node-version }}
- name: Bootstrap
cache: 'yarn'

- name: Install dependencies
run: |
npm run bootstrap
yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Run build
- name: Build code
run: |
npm run build
yarn build
- name: Run tests
run: |
npm run test ci
yarn lint
yarn test ci
- name: Coveralls
if: matrix.node-version == 16
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d # v1.2.5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ github.workspace }}/coverage/lcov.info
8 changes: 1 addition & 7 deletions .ocularrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
/* @type import('ocular-dev-tools').OcularConfig */
export default {
babel: false,

typescript: {
project: 'tsconfig.build.json'
},

lint: {
paths: ['modules', 'examples', 'test']
},

entry: {
test: 'test/node.js',
'test-browser': 'test/browser.js',
'test-browser': 'test/index.html',
bench: 'test/bench/index.ts',
'bench-browser': 'test/bench/browser.ts',
size: ['test/size/log.js', 'test/size/stat.js']
Expand Down
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

16 changes: 0 additions & 16 deletions aliases.js

This file was deleted.

4 changes: 2 additions & 2 deletions examples/browser-test-vite/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {render} from './app.js';
test.onFailure(window.browserTestDriver_fail);
test.onFinish(window.browserTestDriver_finish);

test('A test', t => {
test('A test', (t) => {
// Default tape test timeout is 500ms - allow enough time for render and screenshot
t.timeoutAfter(2000);

Expand All @@ -18,7 +18,7 @@ test('A test', t => {
region: app.getBoundingClientRect(),
saveOnFail: true
})
.then(result => {
.then((result) => {
if (result.error) {
t.fail(String(result.error));
} else {
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-test-webpack/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {render} from './app.js';
test.onFailure(window.browserTestDriver_fail);
test.onFinish(window.browserTestDriver_finish);

test('A test', t => {
test('A test', (t) => {
// Default tape test timeout is 500ms - allow enough time for render and screenshot
t.timeoutAfter(2000);

Expand All @@ -18,7 +18,7 @@ test('A test', t => {
region: app.getBoundingClientRect(),
saveOnFail: true
})
.then(result => {
.then((result) => {
if (result.error) {
t.fail(String(result.error));
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/stats-widget/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class App extends Component {
}

override render() {
return <div id="stats-demo" ref={_ => (this._container = _)} />;
return <div id="stats-demo" ref={(_) => (this._container = _)} />;
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/webpack.config.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function addLocalDevSettings(config, opts) {

module.exports =
(baseConfig, opts = {}) =>
env => {
(env) => {
let config = baseConfig;

if (env && env.local) {
Expand Down
5 changes: 0 additions & 5 deletions lerna-debug.log

This file was deleted.

3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"lerna": "2.9.1",
"version": "4.0.9",
"packages": [
"modules/*",
"examples/*"
"modules/*"
],
"npmClient": "yarn",
"useWorkspaces": true
Expand Down
13 changes: 5 additions & 8 deletions modules/bench/src/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type BenchProps = {
minIterations?: number;
};

export type BenchTestFunction = (testArgs?: unknown) => unknown | Promise<unknown>;
export type BenchTestFunction = <T>(testArgs?: T) => T | Promise<T>;
export type BenchInitFunction = () => unknown;

/** Options for a specific test case */
Expand Down Expand Up @@ -162,6 +162,7 @@ export class Bench {
}

/** Not yet implemented */
// eslint-disable-next-line
calibrate(id?: string, func1?: Function, func2?: Function, props?: {}): this {
return this;
}
Expand Down Expand Up @@ -276,7 +277,7 @@ export class Bench {

// Helper function to promisify setTimeout
function addDelay(timeout: number): Promise<void> {
return new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(() => resolve(), timeout);
});
}
Expand All @@ -290,14 +291,10 @@ function runCalibrationTests({testCases}: {testCases: Record<string, BenchTestCa
}
}

function logEntry(
logFunction: LogFunction,
testCase: BenchTestCase | null,
logEntry: LogEntry
): void {
function logEntry(logFunction: LogFunction, testCase: BenchTestCase | null, entry: LogEntry): void {
const priority = globalThis.probe.priority || 10;
if ((testCase?.priority || 0) <= priority) {
logFunction({...logEntry});
logFunction({...entry});
}
}

Expand Down
8 changes: 4 additions & 4 deletions modules/bench/test/bench.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import {Bench} from '@probe.gl/bench';
import iteratorBench from './iterator.bench';
import parseColorBench from './parse-color.bench';

test('Bench#import', t => {
test('Bench#import', (t) => {
t.equals(typeof Bench, 'function', 'Expected row logged');
t.end();
});

test('Bench#constructor', t => {
test('Bench#constructor', (t) => {
const suite = new Bench({id: 'test'});
t.ok(suite instanceof Bench, 'suite created successfully');
t.end();
});

test('Bench#run', t => {
test('Bench#run', (t) => {
const suite = new Bench({
id: 'test',
log: ({message}) => t.comment(message)
});

suite.add('initFunc in options', {initialize: () => 1, unit: 'initializations'}, value => {
suite.add('initFunc in options', {initialize: () => 1, unit: 'initializations'}, (value) => {
// @ts-expect-error
if (!value === 1) {
t.fail();
Expand Down
2 changes: 1 addition & 1 deletion modules/bench/test/format-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const FORMAT_SI_TESTS = [
{value: 0.0001234, result: '123µ'}
];

test('formatters#formatSI', t => {
test('formatters#formatSI', (t) => {
for (const tc of FORMAT_SI_TESTS) {
const result = formatSI(tc.value);
t.equal(result, tc.result, `formatSI(${tc.value}) should be ${tc.result}`);
Expand Down
Loading

0 comments on commit a7ba6ff

Please sign in to comment.