Skip to content

Commit

Permalink
feat: Switch to ES modules (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored May 2, 2023
1 parent 697bc4e commit d12f484
Show file tree
Hide file tree
Showing 242 changed files with 2,106 additions and 3,663 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ worker/
*.min.js
wip/
picogl/
**/dist/
.cache
.docusaurus

test/apps/
178 changes: 178 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
const {getESLintConfig} = require('ocular-dev-tools/configuration');

// Make any changes to default config here
module.exports = getESLintConfig({
overrides: {
parserOptions: {
project: ['./tsconfig.json']
},

plugins: ['tree-shaking', 'luma-gl-custom-rules', 'import'],

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

rules: {
'no-unused-expressions': 'warn',
'import/no-unresolved': 1,
'no-console': 1,
'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}]
},

overrides: [
{
files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'],
rules: {
'consistent-return': 0, // We use typescript noImplicitReturn
'default-case': 0, // We rely on typescript
'import/no-unresolved': 0,
'import/no-extraneous-dependencies': 0,
'no-unused-expressions': 'warn',
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-misused-promises': 0,
'@typescript-eslint/no-floating-promises': 0,
// For parquet module
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-non-null-asserted-optional-chain': 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': ['warn'],
// 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-unsafe-return': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/restrict-plus-operands': 0
}
},
// tests are run with aliases set up in node and webpack.
// This means lint will not find the imported files and generate false warnings
{
// scripts use devDependencies
files: ['**/test/**/*.js', '**/scripts/**/*.js', '*.config.js', '*.config.local.js'],
rules: {
'import/no-unresolved': 0,
'import/no-extraneous-dependencies': 0
}
},
{
files: ['**/modules/webgpu/**/*.ts', '**/modules/webgpu/**/*.js', "examples/webgpu/**/*.ts"],
globals: {
// TODO - find eslint definitions for WebGPU
"GPU": true,
"GPUAdapter": true,
"GPUAdapterInfo": true,
"GPUBindGroup": true,
"GPUBindGroupLayout": true,
"GPUBuffer": true,
"GPUCanvasContext": true,
"GPUCommandBuffer": true,
"GPUCommandEncoder": true,
"GPUCompilationInfo": true,
"GPUCompilationMessage": true,
"GPUComputePassEncoder": true,
"GPUComputePipeline": true,
"GPUDevice": true,
"GPUDeviceLostInfo": true,
"GPUError": true,
"GPUExternalTexture": true,
"GPUFeatureName": true,
"GPUInternalError": true,
"GPUOutOfMemoryError": true,
"GPUPipelineError": true,
"GPUPipelineLayout": true,
"GPUQuerySet": true,
"GPUQueue": true,
"GPURenderBundle": true,
"GPURenderBundleEncoder": true,
"GPURenderPassEncoder": true,
"GPURenderPipeline": true,
"GPUSampler": true,
"GPUShaderModule": true,
"GPUSupportedLimits": true,
"GPUTexture": true,
"GPUTextureView": true,
"GPUUncapturedErrorEvent": true,
"GPUValidationError": true,
"GPUVertexBufferLayout": true,
"GPUVertexState": true,
"GPUVertexAttribute": true,
"GPUFragmentState": true,
"GPUIndexFormat": true,
"GPURenderPipelineDescriptor": true,
"GPUBufferUsage": true,
"GPUColorWrite": true,
"GPUMapMode": true,
"GPUShaderStage": true,
"GPUTextureUsage": true,
"GPUImageCopyTexture": true,
"GPUImageCopyBuffer": true,
"GPUExtent3D": true,
"GPURenderPassColorAttachment": true,
"GPURenderPassDepthStencilAttachment": true,
"GPUDepthStencilState": true,
"GPUColorTargetState": true,
"GPUBindGroupEntry": true,
"GPUTextureFormat": true,
"GPUBufferUsage": true
}
}
],

settings: {
// Ensure eslint finds typescript files
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx']
}
}
}
},
debug: false
});









147 changes: 0 additions & 147 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist-min/*
dist-buble/*
**/dist/*
website*/public/*
dist.min.js

_docs/
.nyc_output/
Expand Down
31 changes: 22 additions & 9 deletions .ocularrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
const {resolve} = require('path');
import {resolve} from 'path';

module.exports = {
export default {
lint: {
paths: ['modules', 'dev-modules', 'docs', 'test', 'examples'],
extensions: ['js']
paths: ['modules', 'docs', 'test', 'examples'],
extensions: ['js', 'ts']
},

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

aliases: {
// DEV MODULES
// TODO - why is each module not listed?
'dev-modules': resolve(__dirname, './dev-modules'),
'dev-modules': resolve('./dev-modules'),

// TEST
test: resolve(__dirname, './test')
test: resolve('./test')
},

bundle: {
globalName: 'luma',
externals: [],
target: ['supports webgl', 'not dead'],
format: 'umd',
globals: {
'@luma.gl/*': 'globalThis.luma'
}
},

entry: {
test: 'test/index.js',
'test-browser': 'test/browser.js',
test: 'test/index.ts',
'test-browser': 'test/browser.ts',
bench: 'test/bench/index.js',
'bench-browser': 'test/bench/browser.js',
size: 'test/size/import-nothing.js'
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ workers/
wip/
encoding.js
encoding-indexes.js
examples
modules
test
.ocularrc.js
Loading

0 comments on commit d12f484

Please sign in to comment.