Ignore:
Timestamp:
01/21/25 03:08:24 (3 months ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

Location:
imaps-frontend/node_modules/eslint-plugin-react-refresh
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/eslint-plugin-react-refresh/README.md

    r0c6b92a r79a0317  
    11# eslint-plugin-react-refresh [![npm](https://img.shields.io/npm/v/eslint-plugin-react-refresh)](https://www.npmjs.com/package/eslint-plugin-react-refresh)
    22
    3 Validate that your components can safely be updated with fast refresh.
    4 
    5 ## Limitations
    6 
    7 ⚠️ To avoid false positive, by default this plugin is only applied on `tsx` & `jsx` files. See options to run on JS files. ⚠️
    8 
    9 The plugin rely on naming conventions (i.e. use PascalCase for components, camelCase for util functions). This is why there are some limitations:
     3Validate that your components can safely be updated with Fast Refresh.
     4
     5## Explainer
     6
     7"Fast Refresh", also known as "hot reloading", is a feature in many modern bundlers.
     8If you update some React component(s) on disk, then the bundler will know to update only the impacted parts of your page -- without a full page reload.
     9
     10`eslint-plugin-react-refresh` enforces that your components are structured in a way that integrations such as [react-refresh](https://www.npmjs.com/package/react-refresh) expect.
     11
     12### Limitations
     13
     14⚠️ To avoid false positives, by default this plugin is only applied on `tsx` & `jsx` files. See [Options](#options) to run on JS files. ⚠️
     15
     16The plugin relies on naming conventions (i.e. use PascalCase for components, camelCase for util functions). This is why there are some limitations:
    1017
    1118- `export *` are not supported and will be reported as an error
     
    2229## Usage
    2330
    24 ```json
    25 {
    26   "plugins": ["react-refresh"],
    27   "rules": {
    28     "react-refresh/only-export-components": "warn"
    29   }
    30 }
    31 ```
    32 
    33 ### Flat config
     31This plugin provides a single rule, `react-refresh/only-export-components`. There are multiple ways to enable it.
     32
     33### Recommended config
     34
     35```js
     36import reactRefresh from "eslint-plugin-react-refresh";
     37
     38export default [
     39  /* Main config */
     40  reactRefresh.configs.recommended,
     41];
     42```
     43
     44### Vite config
     45
     46This enables the `allowConstantExport` option which is supported by Vite React plugins.
     47
     48```js
     49import reactRefresh from "eslint-plugin-react-refresh";
     50
     51export default [
     52  /* Main config */
     53  reactRefresh.configs.vite,
     54];
     55```
     56
     57### Without config
    3458
    3559```js
     
    4367    },
    4468    rules: {
    45       "react-refresh/only-export-components": "warn",
     69      "react-refresh/only-export-components": "error",
    4670    },
    4771  },
     
    4973```
    5074
    51 ## Fail
     75### Legacy config
     76
     77```jsonc
     78{
     79  "plugins": ["react-refresh"],
     80  "rules": {
     81    "react-refresh/only-export-components": "error"
     82  }
     83}
     84```
     85
     86## Examples
     87
     88These examples are from enabling `react-refresh/only-exports-components`.
     89
     90### Fail
    5291
    5392```jsx
     
    75114```
    76115
    77 ## Pass with allowConstantExport
     116### Pass
     117
     118```jsx
     119export default function Foo() {
     120  return <></>;
     121}
     122```
     123
     124```jsx
     125const foo = () => {};
     126export const Bar = () => <></>;
     127```
     128
     129```jsx
     130import { App } from "./App";
     131createRoot(document.getElementById("root")).render(<App />);
     132```
     133
     134## Options
     135
     136These options are all present on `react-refresh/only-exports-components`.
     137
     138```ts
     139interface Options {
     140  allowExportNames?: string[];
     141  allowConstantExport?: boolean;
     142  customHOCs?: string[];
     143  checkJS?: boolean;
     144}
     145
     146const defaultOptions: Options = {
     147  allowExportNames: [],
     148  allowConstantExport: false,
     149  customHOCs: [],
     150  checkJS: false,
     151};
     152```
     153
     154### allowExportNames <small>(v0.4.4)</small>
     155
     156> Default: `[]`
     157
     158If you use a framework that handles HMR of some specific exports, you can use this option to avoid warning for them.
     159
     160Example for [Remix](https://remix.run/docs/en/main/discussion/hot-module-replacement#supported-exports):
     161
     162```json
     163{
     164  "react-refresh/only-export-components": [
     165    "error",
     166    { "allowExportNames": ["meta", "links", "headers", "loader", "action"] }
     167  ]
     168}
     169```
     170
     171### allowConstantExport <small>(v0.4.0)</small>
     172
     173> Default: `false` (`true` in `vite` config)
     174
     175Don't warn when a constant (string, number, boolean, templateLiteral) is exported aside one or more components.
     176
     177This should be enabled if the fast refresh implementation correctly handles this case (HMR when the constant doesn't change, propagate update to importers when the constant changes.). Vite supports it, PR welcome if you notice other integrations works well.
     178
     179```json
     180{
     181  "react-refresh/only-export-components": [
     182    "error",
     183    { "allowConstantExport": true }
     184  ]
     185}
     186```
     187
     188Enabling this option allows code such as the following:
    78189
    79190```jsx
     
    82193```
    83194
    84 ## Pass
    85 
    86 ```jsx
    87 export default function Foo() {
    88   return <></>;
    89 }
    90 ```
    91 
    92 ```jsx
    93 const foo = () => {};
    94 export const Bar = () => <></>;
    95 ```
    96 
    97 ```jsx
    98 import { App } from "./App";
    99 createRoot(document.getElementById("root")).render(<App />);
    100 ```
    101 
    102 ## Options
    103 
    104 ### allowExportNames <small>(v0.4.4)</small>
    105 
    106 If you use a framework that handles HMR of some specific exports, you can use this option to avoid warning for them.
    107 
    108 Example for [Remix](https://remix.run/docs/en/main/other-api/dev#:~:text=React%20Fast%20Refresh,-can%20only%20handle):
     195### checkJS <small>(v0.3.3)</small>
     196
     197> Default: `false`
     198
     199If your using JSX inside `.js` files (which I don't recommend because it forces you to configure every tool you use to switch the parser), you can still use the plugin by enabling this option. To reduce the number of false positive, only files importing `react` are checked.
     200
     201```json
     202{
     203  "react-refresh/only-export-components": ["error", { "checkJS": true }]
     204}
     205```
     206
     207### customHOCs <small>(v0.4.15)</small>
     208
     209If you're exporting a component wrapped in a custom HOC, you can use this option to avoid false positives.
    109210
    110211```json
    111212{
    112213  "react-refresh/only-export-components": [
    113     "warn",
    114     { "allowExportNames": ["meta", "links", "headers", "loader", "action"] }
     214    "error",
     215    { "customHOCs": ["observer", "withAuth"] }
    115216  ]
    116217}
    117218```
    118 
    119 ### allowConstantExport <small>(v0.4.0)</small>
    120 
    121 Don't warn when a constant (string, number, boolean, templateLiteral) is exported aside one or more components.
    122 
    123 This should be enabled if the fast refresh implementation correctly handles this case (HMR when the constant doesn't change, propagate update to importers when the constant changes.). Vite supports it, PR welcome if you notice other integrations works well.
    124 
    125 ```json
    126 {
    127   "react-refresh/only-export-components": [
    128     "warn",
    129     { "allowConstantExport": true }
    130   ]
    131 }
    132 ```
    133 
    134 ### checkJS <small>(v0.3.3)</small>
    135 
    136 If your using JSX inside `.js` files (which I don't recommend because it forces you to configure every tool you use to switch the parser), you can still use the plugin by enabling this option. To reduce the number of false positive, only files importing `react` are checked.
    137 
    138 ```json
    139 {
    140   "react-refresh/only-export-components": ["warn", { "checkJS": true }]
    141 }
    142 ```
  • imaps-frontend/node_modules/eslint-plugin-react-refresh/index.js

    r0c6b92a r79a0317  
    2121var src_exports = {};
    2222__export(src_exports, {
     23  configs: () => configs,
    2324  default: () => src_default,
    2425  rules: () => rules
     
    2728
    2829// src/only-export-components.ts
    29 var possibleReactExportRE = /^[A-Z][a-zA-Z0-9]*$/u;
    30 var strictReactExportRE = /^[A-Z][a-zA-Z0-9]*[a-z]+[a-zA-Z0-9]*$/u;
     30var reactComponentNameRE = /^[A-Z][a-zA-Z0-9]*$/u;
    3131var onlyExportComponents = {
    3232  meta: {
     
    4444        type: "object",
    4545        properties: {
     46          allowExportNames: { type: "array", items: { type: "string" } },
    4647          allowConstantExport: { type: "boolean" },
    47           checkJS: { type: "boolean" },
    48           allowExportNames: { type: "array", items: { type: "string" } }
     48          customHOCs: { type: "array", items: { type: "string" } },
     49          checkJS: { type: "boolean" }
    4950        },
    5051        additionalProperties: false
     
    5556  create: (context) => {
    5657    const {
     58      allowExportNames,
    5759      allowConstantExport = false,
    58       checkJS = false,
    59       allowExportNames
     60      customHOCs = [],
     61      checkJS = false
    6062    } = context.options[0] ?? {};
    6163    const filename = context.filename;
     
    6769      return {};
    6870    const allowExportNamesSet = allowExportNames ? new Set(allowExportNames) : void 0;
     71    const reactHOCs = ["memo", "forwardRef", ...customHOCs];
     72    const canBeReactFunctionComponent = (init) => {
     73      if (!init)
     74        return false;
     75      if (init.type === "ArrowFunctionExpression")
     76        return true;
     77      if (init.type === "CallExpression" && init.callee.type === "Identifier") {
     78        return reactHOCs.includes(init.callee.name);
     79      }
     80      return false;
     81    };
    6982    return {
    7083      Program(program) {
    7184        let hasExports = false;
    72         let mayHaveReactExport = false;
     85        let hasReactExport = false;
    7386        let reactIsInScope = false;
    7487        const localComponents = [];
     
    7891          if (identifierNode.type !== "Identifier")
    7992            return;
    80           if (possibleReactExportRE.test(identifierNode.name)) {
     93          if (reactComponentNameRE.test(identifierNode.name)) {
    8194            localComponents.push(identifierNode);
    8295          }
     
    96109          }
    97110          if (isFunction) {
    98             if (possibleReactExportRE.test(identifierNode.name)) {
    99               mayHaveReactExport = true;
     111            if (reactComponentNameRE.test(identifierNode.name)) {
     112              hasReactExport = true;
    100113            } else {
    101114              nonComponentExports.push(identifierNode);
     
    112125              return;
    113126            }
    114             if (!mayHaveReactExport && possibleReactExportRE.test(identifierNode.name)) {
    115               mayHaveReactExport = true;
    116             }
    117             if (!strictReactExportRE.test(identifierNode.name)) {
     127            if (reactComponentNameRE.test(identifierNode.name)) {
     128              hasReactExport = true;
     129            } else {
    118130              nonComponentExports.push(identifierNode);
    119131            }
     
    138150          } else if (node.type === "CallExpression") {
    139151            if (node.callee.type === "CallExpression" && node.callee.callee.type === "Identifier" && node.callee.callee.name === "connect") {
    140               mayHaveReactExport = true;
     152              hasReactExport = true;
    141153            } else if (node.callee.type !== "Identifier") {
    142               if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && reactHOCs.has(node.callee.property.name)) {
    143                 mayHaveReactExport = true;
     154              if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && reactHOCs.includes(node.callee.property.name)) {
     155                hasReactExport = true;
    144156              } else {
    145157                context.report({ messageId: "anonymousExport", node });
    146158              }
    147             } else if (!reactHOCs.has(node.callee.name)) {
     159            } else if (!reactHOCs.includes(node.callee.name)) {
    148160              context.report({ messageId: "anonymousExport", node });
    149161            } else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) {
    150162              handleExportIdentifier(node.arguments[0].id, true);
    151163            } else if (((_b = node.arguments[0]) == null ? void 0 : _b.type) === "Identifier") {
    152               mayHaveReactExport = true;
     164              hasReactExport = true;
    153165            } else {
    154166              context.report({ messageId: "anonymousExport", node });
     
    200212          return;
    201213        if (hasExports) {
    202           if (mayHaveReactExport) {
     214          if (hasReactExport) {
    203215            for (const node of nonComponentExports) {
    204216              context.report({ messageId: "namedExport", node });
     
    220232    };
    221233  }
    222 };
    223 var reactHOCs = /* @__PURE__ */ new Set(["memo", "forwardRef"]);
    224 var canBeReactFunctionComponent = (init) => {
    225   if (!init)
    226     return false;
    227   if (init.type === "ArrowFunctionExpression")
    228     return true;
    229   if (init.type === "CallExpression" && init.callee.type === "Identifier") {
    230     return reactHOCs.has(init.callee.name);
    231   }
    232   return false;
    233234};
    234235var notReactComponentExpression = /* @__PURE__ */ new Set([
     
    251252  "only-export-components": onlyExportComponents
    252253};
    253 var src_default = { rules };
     254var plugin = { rules };
     255var configs = {
     256  recommended: {
     257    plugins: { "react-refresh": plugin },
     258    rules: { "react-refresh/only-export-components": "error" }
     259  },
     260  vite: {
     261    plugins: { "react-refresh": plugin },
     262    rules: {
     263      "react-refresh/only-export-components": [
     264        "error",
     265        { allowConstantExport: true }
     266      ]
     267    }
     268  }
     269};
     270var src_default = { rules, configs };
    254271// Annotate the CommonJS export names for ESM import in node:
    2552720 && (module.exports = {
     273  configs,
    256274  rules
    257275});
  • imaps-frontend/node_modules/eslint-plugin-react-refresh/package.json

    r0c6b92a r79a0317  
    11{
    2   "name": "eslint-plugin-react-refresh",
    3   "description": "Validate that your components can safely be updated with fast refresh",
    4   "version": "0.4.14",
    5   "author": "Arnaud Barré (https://github.com/ArnaudBarre)",
    6   "license": "MIT",
    7   "repository": "github:ArnaudBarre/eslint-plugin-react-refresh",
    8   "main": "index.js",
     2  "_development": true,
     3  "_from": "eslint-plugin-react-refresh@0.4.16",
     4  "_id": "eslint-plugin-react-refresh@0.4.16",
     5  "_inBundle": false,
     6  "_integrity": "sha512-slterMlxAhov/DZO8NScf6mEeMBBXodFUolijDvrtTxyezyLoTQaa73FyYus/VbTdftd8wBgBxPMRk3poleXNQ==",
     7  "_location": "/eslint-plugin-react-refresh",
     8  "_phantomChildren": {},
     9  "_requested": {
     10    "type": "version",
     11    "registry": true,
     12    "raw": "eslint-plugin-react-refresh@0.4.16",
     13    "name": "eslint-plugin-react-refresh",
     14    "escapedName": "eslint-plugin-react-refresh",
     15    "rawSpec": "0.4.16",
     16    "saveSpec": null,
     17    "fetchSpec": "0.4.16"
     18  },
     19  "_requiredBy": [
     20    "#DEV:/"
     21  ],
     22  "_resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.16.tgz",
     23  "_shasum": "149dbc9279bd16942409f1c1d2f0dce3299430ef",
     24  "_spec": "eslint-plugin-react-refresh@0.4.16",
     25  "_where": "/home/stevetosak/Proekt/IMaps/imaps-frontend",
     26  "author": {
     27    "name": "Arnaud Barré",
     28    "url": "https://github.com/ArnaudBarre"
     29  },
     30  "bugs": {
     31    "url": "https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues"
     32  },
     33  "bundleDependencies": false,
     34  "deprecated": false,
     35  "description": "Validate that your components can safely be updated with Fast Refresh",
     36  "homepage": "https://github.com/ArnaudBarre/eslint-plugin-react-refresh#readme",
    937  "keywords": [
    1038    "eslint",
     
    1442    "fast refresh"
    1543  ],
     44  "license": "MIT",
     45  "main": "index.js",
     46  "name": "eslint-plugin-react-refresh",
    1647  "peerDependencies": {
    17     "eslint": ">=7"
    18   }
     48    "eslint": ">=8.40"
     49  },
     50  "repository": {
     51    "type": "git",
     52    "url": "git+https://github.com/ArnaudBarre/eslint-plugin-react-refresh.git"
     53  },
     54  "type": "commonjs",
     55  "types": "index.d.ts",
     56  "version": "0.4.16"
    1957}
Note: See TracChangeset for help on using the changeset viewer.