rune-sdk
Version:
Build a multiplayer game played by millions! Your game runs inside the Rune app with 10 million installs across [iOS](https://apps.apple.com/app/rune-games-and-voice-chat/id1450358364) and [Android](https://play.google.com/store/apps/details?id=ai.rune.ti
204 lines (203 loc) • 6.37 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var globals = require("globals");
var index_js_1 = require("./rules/index.js");
var dateErrorMessage = "Use Rune.gameTime()/Rune.worldTime(). Date is only used as helper for date manipulation and providing initial value is mandatory. See https://developers.rune.ai/docs/advanced/real-time-games for more info.";
var restrictedSyntaxBase = [
{
selector: "TryStatement",
message: "Try/catch might prevent Rune from working properly.",
},
{
selector: "ThisExpression,WithStatement",
message: "This references might prevent Rune from working properly.",
},
{
selector: "AwaitExpression,ArrowFunctionExpression[async=true],FunctionExpression[async=true],FunctionDeclaration[async=true],YieldExpression",
message: "Rune logic must be synchronous.",
},
{
selector: "RegExpLiteral",
message: "Regular expressions are stateful and might prevent Rune from working properly.",
},
{
selector: "NewExpression[callee.name='Date'][arguments.length!=1]",
message: dateErrorMessage,
},
{
selector: "CallExpression[callee.name='Date'][arguments.length!=1]",
message: dateErrorMessage,
},
{
selector: "MemberExpression[object.name='Date'][property.name='now']",
message: dateErrorMessage,
},
];
var restrictedGlobals = [
"exports",
"module",
"require",
"window",
"global",
"constructor",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"eval",
"EvalError",
"Function",
"RegExp",
"toLocaleString",
"unescape",
"ArrayBuffer",
"DataView",
"Float32Array",
"Float64Array",
"Int16Array",
"Int32Array",
"Int8Array",
"Promise",
"Proxy",
"Reflect",
"Symbol",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"WeakMap",
"WeakSet",
"Atomics",
"SharedArrayBuffer",
"BigInt",
"BigInt64Array",
"BigUint64Array",
"FinalizationRegistry",
"WeakRef",
"Performance",
"Intl",
"setTimeout",
"clearTimeout",
"setInterval",
"clearInterval",
"alert",
"fetch",
"performance",
"XMLHttpRequest",
];
var plugin = {
meta: {
name: "eslint-plugin-rune",
version: "2.1.0",
},
configs: {
recommended: {},
logic: {},
logicModule: {},
},
rules: index_js_1.rules,
};
// Each validated file yb logicConfig is treated as logic file
var logicConfig = {
plugins: {
rune: plugin,
},
rules: {
"no-restricted-globals": __spreadArray(["error"], restrictedGlobals, true),
"no-undef": 2,
"no-global-assign": 2,
"no-extend-native": 2,
"no-var": 1,
"no-restricted-properties": [
2,
{
object: "Rune",
property: "init",
message: "Rune.init() is restricted to client-only code.",
},
{
object: "Rune",
property: "initClient",
message: "Rune.init() is restricted to client-only code.",
},
{
object: "Rune",
property: "deterministicRandom",
message: "Rune.init() is restricted to client-only code.",
},
{
property: "toLocaleString",
message: "Locale specific operations are not allowed",
},
{
property: "toLocaleLowerCase",
message: "Locale specific operations are not allowed",
},
{
property: "toLocaleUpperCase",
message: "Locale specific operations are not allowed",
},
{
property: "localeCompare",
message: "Locale specific operations are not allowed",
},
{
property: "then",
message: "Promises in logic are not allowed.",
},
],
"no-restricted-syntax": __spreadArray([
"error",
{
selector: "ImportDeclaration,ExportNamedDeclaration[source],ExportAllDeclaration[source],ExportDefaultDeclaration[source]",
message: "Rune logic must be contained in a single file.",
}
], restrictedSyntaxBase, true),
"rune/no-global-scope-mutation": 2,
},
languageOptions: {
ecmaVersion: 2021,
globals: __assign(__assign({}, globals.es2016), { globalThis: "readonly", global: "readonly", Dusk: "readonly", Rune: "readonly", console: "readonly" }),
},
};
//Same as config, except it allows multiple logic files (each validated file is treated as logic file)
var logicModuleConfig = __assign(__assign({}, logicConfig), { rules: __assign(__assign({}, logicConfig.rules), {
//Ignore the rule that logic has to be in one file
"no-restricted-syntax": __spreadArray(["error"], restrictedSyntaxBase, true) }) });
Object.assign(plugin.configs, {
//Only validates logic files
recommended: [
{
languageOptions: {
globals: {
Rune: "readonly",
},
},
},
__assign({ files: ["**/logic.ts", "**/logic.js"] }, logicModuleConfig),
],
logic: logicConfig,
logicModule: logicModuleConfig,
});
module.exports = plugin;