Skip to content

Commit

Permalink
Add @godot/eslint-plugin-ignore-c-preprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamscott committed Dec 17, 2024
1 parent 5a18b0f commit 4334e85
Show file tree
Hide file tree
Showing 8 changed files with 1,856 additions and 1,830 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ repos:
- --config
- platform/web/eslint.config.cjs
additional_dependencies:
- 'https://github.com/godotengine/eslint-plugin-ignore-c-preprocessors/releases/download/0.1.1/godotengine-eslint-plugin-ignore-c-preprocessors-0.1.1.tgz'
- '@eslint/js@^9.3.0'
- '@html-eslint/eslint-plugin@^0.24.1'
- '@html-eslint/parser@^0.24.1'
Expand Down
3 changes: 3 additions & 0 deletions modules/webxr/native/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from "../../../platform/web/eslint.config.cjs";

export default config;
5 changes: 5 additions & 0 deletions modules/webxr/native/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"include": [
"./*.js",
]
}
8 changes: 4 additions & 4 deletions modules/webxr/native/library_godot_webxr.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

const GodotWebXR = {
$GodotWebXR__deps: [
#if EMSCRIPTEN_VERSION_IS_SMALLER_THAN(3,1,71)
#if EMSCRIPTEN_VERSION_IS_LESS_THAN(3,1,71)
'$Browser',
#else
'$MainLoop',
#endif
'$GL',
'$GodotRuntime',
'$runtimeKeepalivePush',
'$runtimeKeepalivePop'
'$runtimeKeepalivePop',
],
$GodotWebXR: {
gl: null,
Expand Down Expand Up @@ -73,7 +73,7 @@ const GodotWebXR = {
}
},
monkeyPatchRequestAnimationFrame: (enable) => {
#if EMSCRIPTEN_VERSION_IS_SMALLER_THAN(3,1,71)
#if EMSCRIPTEN_VERSION_IS_LESS_THAN(3,1,71)
const MainLoop = Browser;
#endif
if (GodotWebXR.orig_requestAnimationFrame === null) {
Expand All @@ -84,7 +84,7 @@ const GodotWebXR = {
: GodotWebXR.orig_requestAnimationFrame;
},
pauseResumeMainLoop: () => {
#if EMSCRIPTEN_VERSION_IS_SMALLER_THAN(3,1,71)
#if EMSCRIPTEN_VERSION_IS_LESS_THAN(3,1,71)
const MainLoop = Browser.mainLoop;
#endif
// Once both GodotWebXR.session and GodotWebXR.space are set or
Expand Down
5 changes: 5 additions & 0 deletions platform/web/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const htmlPlugin = require('@html-eslint/eslint-plugin');
const pluginJs = require('@eslint/js');
const pluginReference = require('eslint-plugin-html');
const stylistic = require('@stylistic/eslint-plugin');
const pluginIgnoreCPreprocessors = require("@godot/eslint-plugin-ignore-c-preprocessors").default;

if (process && process.env && process.env.npm_command && !fs.existsSync('./platform/web/eslint.config.cjs')) {
throw Error('eslint must be run from the Godot project root folder');
Expand Down Expand Up @@ -140,6 +141,10 @@ module.exports = [
// libraries and modules (browser)
{
files: ['js/libs/**/*.js', 'platform/web/js/libs/**/*.js', 'modules/**/*.js'],
plugins: {
"ignore-c-preprocessors": pluginIgnoreCPreprocessors
},
processor: "ignore-c-preprocessors/ignore-c-preprocessors",
languageOptions: {
globals: {
...globals.browser,
Expand Down
12 changes: 8 additions & 4 deletions platform/web/js/libs/library_godot_macros.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable */
{{{
globalThis.___EMSCRIPTEN_VERSION_PARSED = globalThis.EMSCRIPTEN_VERSION.split(".").map((n) => parseInt(n));
/* eslint-enable */
globalThis.___EMSCRIPTEN_VERSION_PARSED = globalThis.EMSCRIPTEN_VERSION.split('.').map((n) => parseInt(n, 10));

globalThis.___SEMVER_IS_GREATER_THAN = (a, b, { orEqual = false } = {}) => {
const [aMajor, aMinor, aPatch] = a;
Expand All @@ -15,7 +17,7 @@
};

globalThis.EMSCRIPTEN_VERSION_IS_GREATER_THAN = (major, minor, patch) => {
const isGreater = globalThis.___SEMVER_IS_GREATER_THAN(globalThis.___EMSCRIPTEN_VERSION_PARSED, [major, minor, patch]);
const isGreater = globalThis.___SEMVER_IS_GREATER_THAN(globalThis.___EMSCRIPTEN_VERSION_PARSED, [major, minor, patch]);
return isGreater;
};

Expand All @@ -24,13 +26,15 @@
return isGreaterOrEqual;
};

globalThis.EMSCRIPTEN_VERSION_IS_SMALLER_THAN = (major, minor, patch) => {
globalThis.EMSCRIPTEN_VERSION_IS_LESS_THAN = (major, minor, patch) => {
const isGreaterOrEqual = globalThis.___SEMVER_IS_GREATER_THAN(globalThis.___EMSCRIPTEN_VERSION_PARSED, [major, minor, patch], { orEqual: true });
return !isGreaterOrEqual;
};

globalThis.EMSCRIPTEN_VERSION_IS_SMALLER_THAN_OR_EQUAL = (major, minor, patch) => {
globalThis.EMSCRIPTEN_VERSION_IS_LESS_THAN_OR_EQUAL = (major, minor, patch) => {
const isGreater = globalThis.___SEMVER_IS_GREATER_THAN(globalThis.___EMSCRIPTEN_VERSION_PARSED, [major, minor, patch]);
return !isGreater;
};
/* eslint-disable */
}}}
/* eslint-enable */
Loading

0 comments on commit 4334e85

Please sign in to comment.