UNPKG

eslint-plugin-o1js

Version:

o1js rules for ESLint

146 lines 3.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const rule_tester_1 = require("../rule-tester"); const no_json_functions_in_circuit_1 = __importDefault(require("../../src/rules/no-json-functions-in-circuit")); const message = 'noJSONFunctionInCircuit'; rule_tester_1.ruleTester.run('no-json-functions-in-circuit', no_json_functions_in_circuit_1.default, { valid: [ { code: ` class Foo { async bar() { let a = JSON.stringify(a) } }`, }, { code: ` class Foo { async bar() { let t = JSON.parse(a) } }`, }, { code: ` class Foo { async bar() { JSON.stringify(a) } }`, }, { code: ` class Foo { async bar() { JSON.parse(a) } }`, }, { code: ` function testJSON() { JSON.parse(a); }; class Foo { async bar() { testJSON(); } }`, }, ], invalid: [ { code: ` class Foo { @method async bar() { let t = JSON.stringify(a) } }`, errors: [{ messageId: message }], }, { code: ` class Foo { @method async bar() { let t = JSON.parse(a) } }`, errors: [{ messageId: message }], }, { code: ` class Foo { @method async bar() { JSON.stringify(a) } }`, errors: [{ messageId: message }], }, { code: ` class Foo { @method async bar() { JSON.parse(a) } }`, errors: [{ messageId: message }], }, { code: ` function testJSON() { JSON.parse(a); }; class Foo { @method async bar() { testJSON(); } }`, errors: [{ messageId: message }], }, { code: ` let testJSON = () => { JSON.parse(a); }; function indirectJSON() { testJSON(); }; class Foo { @method async bar() { indirectJSON(); } }`, errors: [{ messageId: message }], }, { code: ` let testJSON = () => { JSON.stringify(a); }; function indirectJSON() { testJSON(); }; class Foo { @method async bar() { indirectJSON(); } }`, errors: [{ messageId: message }], }, { code: ` let testJSON = () => { let t = JSON.parse(a); }; function indirectJSON() { testJSON(); }; class Foo { @method async bar() { indirectJSON(); } }`, errors: [{ messageId: message }], }, { code: ` let testJSON = () => { let t = JSON.stringify(a); }; function indirectJSON() { testJSON(); }; class Foo { @method async bar() { indirectJSON(); } }`, errors: [{ messageId: message }], }, ], }); //# sourceMappingURL=no-json-functions-in-circuit.test.js.map