@eslint-react/eslint-plugin
Version:
A set of composable linting rules for libraries and frameworks that use React as a UI runtime.
460 lines (434 loc) • 16.6 kB
JavaScript
'use strict';
var reactDebug = require('eslint-plugin-react-debug');
var reactDom = require('eslint-plugin-react-dom');
var reactHooksExtra = require('eslint-plugin-react-hooks-extra');
var reactNamingConvention = require('eslint-plugin-react-naming-convention');
var reactWebApi = require('eslint-plugin-react-web-api');
var react = require('eslint-plugin-react-x');
var shared = require('@eslint-react/shared');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var reactDebug__default = /*#__PURE__*/_interopDefault(reactDebug);
var reactDom__default = /*#__PURE__*/_interopDefault(reactDom);
var reactHooksExtra__default = /*#__PURE__*/_interopDefault(reactHooksExtra);
var reactNamingConvention__default = /*#__PURE__*/_interopDefault(reactNamingConvention);
var reactWebApi__default = /*#__PURE__*/_interopDefault(reactWebApi);
var react__default = /*#__PURE__*/_interopDefault(react);
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name14 in all)
__defProp(target, name14, { get: all[name14], enumerable: true });
};
// package.json
var name = "@eslint-react/eslint-plugin";
var version = "1.41.0";
// src/configs/all.ts
var all_exports = {};
__export(all_exports, {
name: () => name4,
plugins: () => plugins3,
rules: () => rules3,
settings: () => settings3
});
// src/configs/core.ts
var core_exports = {};
__export(core_exports, {
name: () => name2,
plugins: () => plugins,
rules: () => rules,
settings: () => settings
});
var name2 = "@eslint-react/core";
var rules = {
"@eslint-react/jsx-no-duplicate-props": "warn",
"@eslint-react/jsx-uses-react": "warn",
"@eslint-react/jsx-uses-vars": "warn",
"@eslint-react/no-access-state-in-setstate": "error",
"@eslint-react/no-array-index-key": "warn",
"@eslint-react/no-children-count": "warn",
"@eslint-react/no-children-for-each": "warn",
"@eslint-react/no-children-map": "warn",
"@eslint-react/no-children-only": "warn",
"@eslint-react/no-children-to-array": "warn",
"@eslint-react/no-clone-element": "warn",
"@eslint-react/no-comment-textnodes": "warn",
"@eslint-react/no-component-will-mount": "error",
"@eslint-react/no-component-will-receive-props": "error",
"@eslint-react/no-component-will-update": "error",
"@eslint-react/no-context-provider": "warn",
"@eslint-react/no-create-ref": "error",
"@eslint-react/no-default-props": "error",
"@eslint-react/no-direct-mutation-state": "error",
"@eslint-react/no-duplicate-key": "warn",
"@eslint-react/no-forward-ref": "warn",
"@eslint-react/no-implicit-key": "warn",
"@eslint-react/no-missing-key": "error",
"@eslint-react/no-nested-component-definitions": "error",
"@eslint-react/no-prop-types": "error",
"@eslint-react/no-redundant-should-component-update": "error",
"@eslint-react/no-set-state-in-component-did-mount": "warn",
"@eslint-react/no-set-state-in-component-did-update": "warn",
"@eslint-react/no-set-state-in-component-will-update": "warn",
"@eslint-react/no-string-refs": "error",
"@eslint-react/no-unsafe-component-will-mount": "warn",
"@eslint-react/no-unsafe-component-will-receive-props": "warn",
"@eslint-react/no-unsafe-component-will-update": "warn",
"@eslint-react/no-unstable-context-value": "warn",
"@eslint-react/no-unstable-default-props": "warn",
"@eslint-react/no-unused-class-component-members": "warn",
"@eslint-react/no-unused-state": "warn",
"@eslint-react/no-use-context": "warn",
"@eslint-react/no-useless-forward-ref": "warn"
};
var plugins = {
"@eslint-react": react__default.default
};
var settings = {
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
};
// src/configs/dom.ts
var dom_exports = {};
__export(dom_exports, {
name: () => name3,
plugins: () => plugins2,
rules: () => rules2,
settings: () => settings2
});
var name3 = "@eslint-react/dom";
var rules2 = {
"@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
"@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
"@eslint-react/dom/no-find-dom-node": "error",
"@eslint-react/dom/no-flush-sync": "error",
"@eslint-react/dom/no-hydrate": "error",
"@eslint-react/dom/no-missing-button-type": "warn",
"@eslint-react/dom/no-missing-iframe-sandbox": "warn",
"@eslint-react/dom/no-namespace": "error",
"@eslint-react/dom/no-render": "error",
"@eslint-react/dom/no-render-return-value": "error",
"@eslint-react/dom/no-script-url": "warn",
"@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
"@eslint-react/dom/no-unsafe-target-blank": "warn",
"@eslint-react/dom/no-use-form-state": "error",
"@eslint-react/dom/no-void-elements-with-children": "error"
};
var plugins2 = {
"@eslint-react/dom": reactDom__default.default
};
var settings2 = {
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
};
// src/configs/all.ts
var name4 = "@eslint-react/all";
var rules3 = {
"@eslint-react/avoid-shorthand-boolean": "warn",
"@eslint-react/avoid-shorthand-fragment": "warn",
"@eslint-react/jsx-no-duplicate-props": "warn",
"@eslint-react/jsx-no-undef": "error",
"@eslint-react/jsx-uses-react": "warn",
"@eslint-react/jsx-uses-vars": "warn",
"@eslint-react/no-access-state-in-setstate": "error",
"@eslint-react/no-array-index-key": "warn",
"@eslint-react/no-children-count": "warn",
"@eslint-react/no-children-for-each": "warn",
"@eslint-react/no-children-map": "warn",
"@eslint-react/no-children-only": "warn",
"@eslint-react/no-children-prop": "warn",
"@eslint-react/no-children-to-array": "warn",
"@eslint-react/no-class-component": "warn",
"@eslint-react/no-clone-element": "warn",
"@eslint-react/no-comment-textnodes": "warn",
"@eslint-react/no-complex-conditional-rendering": "warn",
"@eslint-react/no-component-will-mount": "error",
"@eslint-react/no-component-will-receive-props": "error",
"@eslint-react/no-component-will-update": "error",
"@eslint-react/no-context-provider": "warn",
"@eslint-react/no-create-ref": "error",
"@eslint-react/no-default-props": "error",
"@eslint-react/no-direct-mutation-state": "error",
"@eslint-react/no-duplicate-key": "warn",
"@eslint-react/no-forward-ref": "warn",
"@eslint-react/no-implicit-key": "warn",
"@eslint-react/no-missing-component-display-name": "warn",
"@eslint-react/no-missing-context-display-name": "warn",
"@eslint-react/no-missing-key": "error",
"@eslint-react/no-nested-component-definitions": "error",
"@eslint-react/no-prop-types": "error",
"@eslint-react/no-redundant-should-component-update": "error",
"@eslint-react/no-set-state-in-component-did-mount": "warn",
"@eslint-react/no-set-state-in-component-did-update": "warn",
"@eslint-react/no-set-state-in-component-will-update": "warn",
"@eslint-react/no-string-refs": "error",
"@eslint-react/no-unsafe-component-will-mount": "warn",
"@eslint-react/no-unsafe-component-will-receive-props": "warn",
"@eslint-react/no-unsafe-component-will-update": "warn",
"@eslint-react/no-unstable-context-value": "warn",
"@eslint-react/no-unstable-default-props": "warn",
"@eslint-react/no-unused-class-component-members": "warn",
"@eslint-react/no-unused-state": "warn",
"@eslint-react/no-use-context": "warn",
"@eslint-react/no-useless-forward-ref": "warn",
"@eslint-react/no-useless-fragment": "warn",
"@eslint-react/prefer-destructuring-assignment": "warn",
"@eslint-react/prefer-shorthand-boolean": "off",
"@eslint-react/prefer-shorthand-fragment": "off",
"@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
"@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
"@eslint-react/dom/no-find-dom-node": "error",
"@eslint-react/dom/no-flush-sync": "error",
"@eslint-react/dom/no-hydrate": "error",
"@eslint-react/dom/no-missing-button-type": "warn",
"@eslint-react/dom/no-missing-iframe-sandbox": "warn",
"@eslint-react/dom/no-namespace": "error",
"@eslint-react/dom/no-render": "error",
"@eslint-react/dom/no-render-return-value": "error",
"@eslint-react/dom/no-script-url": "warn",
"@eslint-react/dom/no-unknown-property": "warn",
"@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
"@eslint-react/dom/no-unsafe-target-blank": "warn",
"@eslint-react/dom/no-use-form-state": "error",
"@eslint-react/dom/no-void-elements-with-children": "error",
"@eslint-react/web-api/no-leaked-event-listener": "warn",
"@eslint-react/web-api/no-leaked-interval": "warn",
"@eslint-react/web-api/no-leaked-resize-observer": "warn",
"@eslint-react/web-api/no-leaked-timeout": "warn",
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
"@eslint-react/hooks-extra/no-direct-set-state-in-use-layout-effect": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-callback": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-memo": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": "warn",
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
"@eslint-react/naming-convention/component-name": "warn",
"@eslint-react/naming-convention/context-name": "warn",
"@eslint-react/naming-convention/filename": "warn",
"@eslint-react/naming-convention/filename-extension": "warn",
"@eslint-react/naming-convention/use-state": "warn"
};
var plugins3 = {
...plugins,
...plugins2,
"@eslint-react/debug": reactDebug__default.default,
"@eslint-react/hooks-extra": reactHooksExtra__default.default,
"@eslint-react/naming-convention": reactNamingConvention__default.default,
"@eslint-react/web-api": reactWebApi__default.default
};
var settings3 = {
...settings2
};
// src/configs/debug.ts
var debug_exports = {};
__export(debug_exports, {
name: () => name5,
plugins: () => plugins4,
rules: () => rules4
});
var name5 = "@eslint-react/debug";
var rules4 = {
"@eslint-react/debug/class-component": "warn",
"@eslint-react/debug/function-component": "warn",
"@eslint-react/debug/hook": "warn",
"@eslint-react/debug/is-from-react": "warn"
};
var plugins4 = {
"@eslint-react/debug": reactDebug__default.default
};
// src/configs/disable-debug.ts
var disable_debug_exports = {};
__export(disable_debug_exports, {
name: () => name6,
rules: () => rules5
});
var name6 = "@eslint-react/disable-debug";
var rules5 = Object.fromEntries(Object.entries(rules4).map(([rule]) => [rule, "off"]));
// src/configs/disable-dom.ts
var disable_dom_exports = {};
__export(disable_dom_exports, {
name: () => name7,
rules: () => rules6
});
var name7 = "@eslint-react/disable-dom";
var rules6 = Object.fromEntries(Object.entries(rules2).map(([key]) => [key, "off"]));
// src/configs/disable-type-checked.ts
var disable_type_checked_exports = {};
__export(disable_type_checked_exports, {
name: () => name8,
rules: () => rules7
});
var name8 = "@eslint-react/disable-type-checked";
var rules7 = {
"@eslint-react/no-leaked-conditional-rendering": "off",
"@eslint-react/prefer-read-only-props": "off"
};
// src/configs/disable-web-api.ts
var disable_web_api_exports = {};
__export(disable_web_api_exports, {
name: () => name9,
rules: () => rules9
});
var rules8 = {
"@eslint-react/web-api/no-leaked-event-listener": "warn",
"@eslint-react/web-api/no-leaked-interval": "warn",
"@eslint-react/web-api/no-leaked-resize-observer": "warn",
"@eslint-react/web-api/no-leaked-timeout": "warn"
};
var plugins5 = {
"@eslint-react/web-api": reactWebApi__default.default
};
// src/configs/disable-web-api.ts
var name9 = "@eslint-react/disable-web-api";
var rules9 = Object.fromEntries(Object.entries(rules8).map(([key]) => [key, "off"]));
// src/configs/off.ts
var off_exports = {};
__export(off_exports, {
name: () => name10,
rules: () => rules10
});
var name10 = "@eslint-react/off";
var rules10 = {
...Object.fromEntries(Object.entries(rules3).map(([key]) => [key, "off"])),
...rules7
};
// src/configs/recommended.ts
var recommended_exports = {};
__export(recommended_exports, {
name: () => name11,
plugins: () => plugins6,
rules: () => rules11,
settings: () => settings5
});
var name11 = "@eslint-react/recommended";
var rules11 = {
...rules,
...rules2,
...rules8,
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": "warn",
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
"@eslint-react/naming-convention/context-name": "warn"
// "@eslint-react/naming-convention/use-state": "warn",
};
var plugins6 = {
...plugins,
...plugins2,
...plugins5,
"@eslint-react/debug": reactDebug__default.default,
"@eslint-react/hooks-extra": reactHooksExtra__default.default,
"@eslint-react/naming-convention": reactNamingConvention__default.default
};
var settings5 = {
...settings2
};
// src/configs/recommended-type-checked.ts
var recommended_type_checked_exports = {};
__export(recommended_type_checked_exports, {
name: () => name13,
plugins: () => plugins8,
rules: () => rules13,
settings: () => settings7
});
// src/configs/recommended-typescript.ts
var recommended_typescript_exports = {};
__export(recommended_typescript_exports, {
name: () => name12,
plugins: () => plugins7,
rules: () => rules12,
settings: () => settings6
});
var name12 = "@eslint-react/recommended-typescript";
var rules12 = {
...rules11,
"@eslint-react/dom/no-unknown-property": "off",
"@eslint-react/jsx-no-duplicate-props": "off",
"@eslint-react/jsx-uses-react": "off",
"@eslint-react/jsx-uses-vars": "off"
};
var plugins7 = {
...plugins6
};
var settings6 = {
...settings5
};
// src/configs/recommended-type-checked.ts
var name13 = "@eslint-react/recommended-type-checked";
var rules13 = {
...rules12,
"@eslint-react/no-leaked-conditional-rendering": "warn"
// "@eslint-react/prefer-read-only-props": "warn",
};
var plugins8 = {
...plugins7
};
var settings7 = {
...settings6
};
// src/utils/type-of.ts
function typeOf(t) {
return Object.prototype.toString.call(t).replace(/^\[object (.+)\]$/, "$1").toLowerCase();
}
// src/utils/transform-keys.ts
function transformKeys(obj, transform) {
if (typeOf(obj) !== "object") {
return obj;
}
const res = {};
for (const key in obj) {
res[transform(key)] = obj[key];
}
return res;
}
// src/utils/pad-keys-left.ts
function padKeysLeft(obj, left) {
return transformKeys(obj, (key) => `${left}${key}`);
}
// src/index.ts
function toLegacyConfig({ rules: rules14 }) {
return {
plugins: ["@eslint-react"],
rules: rules14
};
}
var index_default = {
meta: {
name,
version
},
configs: {
["all"]: all_exports,
["all-legacy"]: toLegacyConfig(all_exports),
["core"]: core_exports,
["core-legacy"]: toLegacyConfig(core_exports),
["debug"]: debug_exports,
["debug-legacy"]: toLegacyConfig(debug_exports),
["disable-debug"]: disable_debug_exports,
["disable-debug-legacy"]: toLegacyConfig(disable_debug_exports),
["disable-dom"]: disable_dom_exports,
["disable-dom-legacy"]: toLegacyConfig(disable_dom_exports),
["disable-type-checked"]: disable_type_checked_exports,
["disable-type-checked-legacy"]: toLegacyConfig(disable_type_checked_exports),
["disable-web-api"]: disable_web_api_exports,
["disable-web-api-legacy"]: toLegacyConfig(disable_web_api_exports),
["dom"]: dom_exports,
["dom-legacy"]: toLegacyConfig(dom_exports),
["off"]: off_exports,
["off-legacy"]: toLegacyConfig(off_exports),
["recommended"]: recommended_exports,
["recommended-legacy"]: toLegacyConfig(recommended_exports),
["recommended-type-checked"]: recommended_type_checked_exports,
["recommended-type-checked-legacy"]: toLegacyConfig(recommended_type_checked_exports),
["recommended-typescript"]: recommended_typescript_exports,
["recommended-typescript-legacy"]: toLegacyConfig(recommended_typescript_exports),
// Part: deprecated presets
/** @deprecated Use `disable-dom` instead */
["off-dom"]: disable_dom_exports,
/** @deprecated Use `disable-dom-legacy` instead */
["off-dom-legacy"]: toLegacyConfig(disable_dom_exports)
},
rules: {
...react__default.default.rules,
...padKeysLeft(reactDom__default.default.rules, "dom/"),
...padKeysLeft(reactWebApi__default.default.rules, "web-api/"),
...padKeysLeft(reactHooksExtra__default.default.rules, "hooks-extra/"),
...padKeysLeft(reactNamingConvention__default.default.rules, "naming-convention/"),
...padKeysLeft(reactDebug__default.default.rules, "debug/")
}
};
module.exports = index_default;