UNPKG

@stencil/eslint-plugin

Version:

ESLint rules specific to Stencil JS projects.

137 lines (136 loc) 3.97 kB
//#region src/configs/base.ts var base_default = { overrides: [{ files: ["*.ts", "*.tsx"], parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: 2018, sourceType: "module", ecmaFeatures: { jsx: true } }, env: { es2020: true, browser: true }, plugins: ["stencil"], rules: { "stencil/async-methods": 2, "stencil/ban-prefix": [2, [ "stencil", "stnl", "st" ]], "stencil/decorators-context": 2, "stencil/element-type": 2, "stencil/host-data-deprecated": 2, "stencil/methods-must-be-public": 2, "stencil/no-unused-watch": 2, "stencil/prefer-vdom-listener": 2, "stencil/props-must-be-public": 2, "stencil/render-returns-host": 2, "stencil/reserved-member-names": 2, "stencil/single-export": 2 } }], settings: { react: { version: "stencil-maintainers-put-an-invalid-version-intentionally-if-this-errors-please-raise-an-issue-https://github.com/stenciljs/eslint-plugin/issues" } } }; //#endregion //#region src/configs/recommended.ts var recommended_default = { plugins: ["react"], extends: ["plugin:stencil/base"], rules: { "stencil/strict-boolean-conditions": 1, "stencil/ban-default-true": 1, "stencil/ban-exported-const-enums": 2, "stencil/ban-side-effects": 2, "stencil/strict-mutable": 2, "stencil/decorators-style": ["error", { prop: "inline", state: "inline", element: "inline", event: "inline", method: "multiline", watch: "multiline", listen: "multiline" }], "stencil/own-methods-must-be-private": 1, "stencil/own-props-must-be-private": 1, "stencil/dependency-suggestions": 1, "stencil/required-jsdoc": 1, "stencil/enforce-slot-jsdoc": 1, "react/jsx-no-bind": [1, { ignoreRefs: true }] } }; //#endregion //#region src/configs/oxlint.ts const SEVERITY_BY_NUMBER = { 0: "off", 1: "warn", 2: "error" }; function toSeverity(value) { return typeof value === "string" ? value : SEVERITY_BY_NUMBER[value]; } function normalize(entry) { if (Array.isArray(entry)) { const [severity, ...options] = entry; return [toSeverity(severity), ...options]; } return toSeverity(entry); } /** * Rule set for oxlint's `.oxlintrc.json`, loaded via `jsPlugins`. Unlike the * ESLint flat configs, this only carries `stencil/*` rules - oxlint has its * own built-in `react` plugin, so `eslint-plugin-react` rules from * {@link recommended} are not applicable here. Severities are normalized to * oxlint's string form ("off"/"warn"/"error") rather than the numeric form * the legacy `.eslintrc` configs use, since oxlint users read them directly * out of `.oxlintrc.json`. */ function stencilRulesOf(rules) { return Object.fromEntries(Object.entries(rules).filter(([name]) => name.startsWith("stencil/")).map(([name, entry]) => [name, normalize(entry)])); } //#endregion //#region src/configs/index.ts var configs_default = { base: base_default, recommended: recommended_default, strict: { extends: [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:stencil/recommended" ], rules: { "stencil/ban-default-true": 2, "stencil/strict-boolean-conditions": 2, "@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/no-this-alias": 0, "@typescript-eslint/no-non-null-assertion": 0, "@typescript-eslint/no-unused-vars": 0, "@typescript-eslint/no-empty-interface": 0, "@typescript-eslint/no-use-before-define": 0, "@typescript-eslint/no-explicit-any": 0, "no-shadow": 2, "no-var": 2, "prefer-object-spread": 2, "no-nested-ternary": 2, "no-duplicate-imports": 2, curly: [2, "all"] } }, oxlint: { ...stencilRulesOf(base_default.overrides[0].rules), ...stencilRulesOf(recommended_default.rules) }, /** * will be populated in `/src/index.ts` * For backward compatibility */ flat: {} }; //#endregion export { configs_default as t }; //# sourceMappingURL=configs-Ciyc5czw.js.map