@builder.io/eslint-plugin-mitosis
Version:
A Mitosis plugin containing rules that help you write valid and idiomatic Mitosis code
37 lines (36 loc) • 1.45 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
var eslint_1 = require("eslint");
var static_control_flow_1 = require("../static-control-flow");
var ruleTester = new eslint_1.RuleTester();
var options = {
filename: 'component.lite.tsx',
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
};
ruleTester.run('static-control-flow', static_control_flow_1.staticControlFlow, {
valid: [
__assign(__assign({}, options), { code: '<Show when={foo}>{bar}</Show>' }),
__assign(__assign({}, options), { code: '<For each={list}>{item => <span />}</For>' }),
__assign(__assign({}, options), { code: '<div>{list.map(item => <span />)}</div>' }),
],
invalid: [
__assign(__assign({}, options), { code: '<div>{foo ? <div /> : <span />}</div>', errors: [{ message: /Ternaries/i }] }),
],
});