Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update engine and examples package.json #7172

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import babelParser from '@babel/eslint-parser';
import globals from 'globals';

export default [
...playcanvasConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
parser: babelParser,
parserOptions: {
requireConfigFile: false
},
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
'Ammo': 'readonly',
'earcut': 'readonly',
'opentype': 'readonly',
'pc': 'readonly',
'TWEEN': 'readonly',
'twgsl': 'readonly',
'webkitAudioContext': 'readonly'
}
},
rules: {
'import/order': 'off'
}
},
{
files: ['scripts/**/*.js'],
rules: {
'no-var': 'off'
}
},
{
files: ['test/**/*.mjs'],
rules: {
'no-unused-expressions': 'off',
'prefer-arrow-callback': 'off' // Mocha uses function callbacks
}
},
{
ignores: [
'tests/**/*',
'examples/lib/*',
'scripts/textmesh/*.min.js',
'src/polyfill/*',
'scripts/spine/*'
]
}
];
30 changes: 30 additions & 0 deletions examples/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import globals from 'globals';

export default [
...playcanvasConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
'ObjModelParser': 'readonly',
'OutlineEffect': 'readonly'
}
},
rules: {
'import/no-unresolved': 'off'
}
},
{
ignores: [
'assets/scripts/utils/area-light-lut-bin-gen.js',
'cache',
'dist',
'src/lib',
'src/app/monaco/languages',
'src/app/monaco/tokenizer-rules.mjs'
]
}
];
6 changes: 3 additions & 3 deletions examples/iframe/loader.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { updateDeviceType, fetchFile, localImport, clearImports, parseConfig, fire } from 'examples/utils';
import { data, refresh } from 'examples/observer';
import files from 'examples/files';
import { data, refresh } from 'examples/observer';
import { updateDeviceType, fetchFile, localImport, clearImports, parseConfig, fire } from 'examples/utils';

import MiniStats from './ministats.mjs';

Expand Down Expand Up @@ -79,7 +79,7 @@ class ExampleLoader {
*/
const locations = [];
lines.forEach((line) => {
const match = /^\s*at\s(.+):(\d+):(\d+)$/g.exec(line);
const match = /^\s*at\s(.+):(\d+):(\d+)$/.exec(line);
if (!match) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/iframe/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const rootPath = root.replace(/\/iframe/g, '');
*/
export function getQueryParams(url) {
return Object.fromEntries(url
.split('?').pop()
.split('#')[0]
.split('&').map(s => s.split('=')));
.split('?').pop()
.split('#')[0]
.split('&').map(s => s.split('=')));
}

/**
Expand Down Expand Up @@ -80,14 +80,14 @@ export function clearImports() {
* @returns {Record<string, any>} - The parsed config.
*/
export function parseConfig(script) {
const regex = /\/\/ @config ([^ \n]+) ?([^\n]+)?/g;
const regex = /\/\/ @config (\S+)(?:\s+([^\n]+))?/g;
let match;
/** @type {Record<string, any>} */
const config = {};
while ((match = regex.exec(script)) !== null) {
const key = match[1].trim();
const val = match[2]?.trim();
config[key] = /true|false/g.test(val) ? val === 'true' : val ?? true;
config[key] = /true|false/.test(val) ? val === 'true' : val ?? true;
}
return config;
}
Expand All @@ -104,7 +104,7 @@ export function updateDeviceType(config) {
deviceType = DEVICE_TYPES.includes(savedDevice) ? savedDevice : 'webgl2';

if (params.deviceType && DEVICE_TYPES.includes(params.deviceType)) {
console.warn("Overriding default device: ", params.deviceType);
console.warn('Overriding default device: ', params.deviceType);
deviceType = params.deviceType;
return;
}
Expand Down
Loading
Loading