eslint-plugin-use-agnostic 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -80,7 +80,7 @@ Aliased import paths are resolved only if your ESLint config file and your `tsco
80
80
 
81
81
  It is up to you to confirm that your Agnostic Modules are indeed agnostic, meaning that they have neither server- nor client-side code. `eslint-plugin-use-agnostic`, at least at this time, does not do this verification for you.
82
82
 
83
- It is also up to you to ensure, as outlined above, that **you do not mix** exporting React components with exporting other logics within the same module. Separating exporting React components within their own modules ending with a JSX extension, from exporting other logics within modules that don't end with a JSX extension, is crucial for distinguishing between Logics Modules and Components Modules.
83
+ It is also up to you to ensure, as outlined above, that **you do not mix** exporting React components with exporting other logics within the same module. Separating exporting React components within their own modules ending with a JSX file extension, from exporting other logics within modules that don't end with a JSX file extension, is crucial for distinguishing between Components Modules and Logics Modules respectively.
84
84
 
85
85
  The import rules are designed to be as permissive as possible, allowing for more obscure use cases as long as they are non-breaking. However, it is still your responsibility as a developer to, within a file, not mix in incompatible ways code that cannot compose.
86
86
 
@@ -88,11 +88,11 @@ The import rules are designed to be as permissive as possible, allowing for more
88
88
 
89
89
  I believe the core issue hindering the comprehension of React Server Components is the fact that the Fullstack React Architecture has entirely erased its own roots since the introduction of directives by disregarding the architecture's primordial realities I have detailed above: its Modules. Server Modules. Client Modules. Agnostic Modules.
90
90
 
91
- 'use client' may denote to the server that a module's exports are to be imported as client references. But that effectively makes said module a "'use client' module", and it's only natural that a "'use client' module" would behave in a 'use client' way.
91
+ `'use client'` may denote to the server that a module's exports are to be imported as client references. But that effectively makes said module a "`'use client'` module", and it's only natural that a "`'use client'` module" would behave in a `'use client'` way.
92
92
 
93
- 'use server' may denote to the client that a module's exports are to be imported as server references. But that effectively makes said module a "'use server' module", and it's only natural that a "'use server' module" would behave in a 'use server' way.
93
+ `'use server'` may denote to the client that a module's exports are to be imported as server references. But that effectively makes said module a "`'use server'` module", and it's only natural that a "`'use server'` module" would behave in a `'use server'` way.
94
94
 
95
- React can easily understand that a 'use client' module is, from a primordial standpoint, a Client Module. And it can also understand that a 'use server' module is a Server Module, albeit a special one.
95
+ React can easily understand that a `'use client'` module is, from a primordial standpoint, a Client Module. And it can also understand that a `'use server'` module is a Server Module, albeit a special one.
96
96
 
97
97
  But not having a directive to distinguish between 1. non-special Server Modules that are never meant to be imported on the client, even as references; and 2. actual Agnostic Modules, the Shared Modules that are still here at the heart of this system and are able to run anywhere; this creates a confusion that is detrimental to every single stackholder in the RSC ecosystem:
98
98
 
@@ -100,6 +100,6 @@ But not having a directive to distinguish between 1. non-special Server Modules
100
100
  - LLMs are confused, because even they can't understand what 'use server' and 'use client' mean and therefore cannot explain it to developers facing their own specific concerns.
101
101
  - And if LLMs are confused, I can't even imagine what that must mean for AI tools and AI agents.
102
102
 
103
- This is what the 'use agnostic' directive solves. It clearly marks a module to be an Agnostic Module. And if a module that used to lack a directive can now be marked as an Agnostic Module, this allows modules without a directive to finally, truly be Server Modules by default. And eslint-plugin-use-agnostic can work from there.
103
+ This is what the `'use agnostic'` directive solves. It clearly marks a module to be an Agnostic Module. And if a module that used to lack a directive can now be marked as an Agnostic Module, this allows modules without a directive to finally, truly be Server Modules by default. And `eslint-plugin-use-agnostic` can work from there.
104
104
 
105
- A lot more needs to be done, and a lot of it unfortunately can only be optimized deeper into React's innerworkings. But if the introduction of 'use agnostic' can already create such powerful static analysis, imagine what it could produce if only it were incorporated into React as an official directive of the Fullstack React Architecture.
105
+ A lot more needs to be done, and a lot of it unfortunately can only be optimized deeper into React's innerworkings. But if the introduction of `'use agnostic'` can already create such powerful static analysis, imagine what it could produce if only it were incorporated into React as an official directive of the Fullstack React Architecture.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -1,23 +0,0 @@
1
- import {
2
- verifySpecifierImportRuleName,
3
- verifyDefaultImportRuleName,
4
- verifyNamespaceImportRuleName,
5
- } from "../../../../_commons/constants/bases.js";
6
-
7
- import verifySpecifierImportExportSameStrategy from "../rules/specifiers.js";
8
- import verifyDefaultImportExportSameStrategy from "../rules/defaults.js";
9
- import verifyNamespaceImportExportSomeStrategy from "../rules/namespaces.js";
10
-
11
- // The name of the plugin is `strategies`.
12
- // This is the strategies plugin.
13
-
14
- /** @type {import('eslint').ESLint.Plugin} */
15
- const plugin = {
16
- rules: {
17
- [verifySpecifierImportRuleName]: verifySpecifierImportExportSameStrategy,
18
- [verifyDefaultImportRuleName]: verifyDefaultImportExportSameStrategy,
19
- [verifyNamespaceImportRuleName]: verifyNamespaceImportExportSomeStrategy,
20
- },
21
- };
22
-
23
- export default plugin;
@@ -1,56 +0,0 @@
1
- import {
2
- USE_SERVER_LOGICS,
3
- USE_CLIENT_LOGICS,
4
- USE_AGNOSTIC_LOGICS,
5
- USE_SERVER_COMPONENTS,
6
- USE_CLIENT_COMPONENTS,
7
- USE_AGNOSTIC_COMPONENTS,
8
- USE_SERVER_FUNCTIONS,
9
- USE_CLIENT_CONTEXTS,
10
- USE_AGNOSTIC_CONDITIONS,
11
- } from "../../../_commons/constants/bases.js";
12
-
13
- // The name of the rule is `verify-default-import-export-same-strategy`.
14
- // This is the verify-default-import-export-same-strategy rule.
15
-
16
- /** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<string, []>} */ // string for now
17
- const rule = {
18
- meta: {
19
- type: "problem",
20
- docs: {
21
- description:
22
- "Verifies that a default import and export have the same strategy. ",
23
- },
24
- schema: [
25
- {
26
- // importingFileCommentedDirective
27
- enum: [
28
- USE_SERVER_LOGICS,
29
- USE_CLIENT_LOGICS,
30
- USE_AGNOSTIC_LOGICS,
31
- USE_SERVER_COMPONENTS,
32
- USE_CLIENT_COMPONENTS,
33
- USE_AGNOSTIC_COMPONENTS,
34
- USE_SERVER_FUNCTIONS,
35
- USE_CLIENT_CONTEXTS,
36
- USE_AGNOSTIC_CONDITIONS,
37
- ],
38
- },
39
- {
40
- // importedName (because stemming from the same makeConfig)
41
- type: "undefined",
42
- },
43
- ],
44
- messages: {},
45
- },
46
- create: (context) => {
47
- return {
48
- ExportDefaultDeclaration: (node) => {
49
- console.log("verify-default-import-export-same-strategy");
50
- console.log(node);
51
- },
52
- };
53
- },
54
- };
55
-
56
- export default rule; // verify-default-import-export-same-strategy
@@ -1,61 +0,0 @@
1
- import {
2
- USE_SERVER_LOGICS,
3
- USE_CLIENT_LOGICS,
4
- USE_AGNOSTIC_LOGICS,
5
- USE_SERVER_COMPONENTS,
6
- USE_CLIENT_COMPONENTS,
7
- USE_AGNOSTIC_COMPONENTS,
8
- USE_SERVER_FUNCTIONS,
9
- USE_CLIENT_CONTEXTS,
10
- USE_AGNOSTIC_CONDITIONS,
11
- } from "../../../_commons/constants/bases.js";
12
-
13
- // The name of the rule is `verify-namespace-import-export-some-strategy`.
14
- // This is the verify-namespace-import-export-some-strategy rule.
15
-
16
- /** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<string, []>} */ // string for now
17
- const rule = {
18
- meta: {
19
- type: "problem",
20
- docs: {
21
- description:
22
- "Verifies that a specifier's import and export have the same strategy. ",
23
- },
24
- schema: [
25
- {
26
- // importingFileCommentedDirective
27
- enum: [
28
- USE_SERVER_LOGICS,
29
- USE_CLIENT_LOGICS,
30
- USE_AGNOSTIC_LOGICS,
31
- USE_SERVER_COMPONENTS,
32
- USE_CLIENT_COMPONENTS,
33
- USE_AGNOSTIC_COMPONENTS,
34
- USE_SERVER_FUNCTIONS,
35
- USE_CLIENT_CONTEXTS,
36
- USE_AGNOSTIC_CONDITIONS,
37
- ],
38
- },
39
- {
40
- // importedName (because stemming from the same makeConfig)
41
- type: "undefined",
42
- },
43
- ],
44
- messages: {},
45
- },
46
- create: (context) => {
47
- return {
48
- ExportSpecifier: (node) => {
49
- console.log("verify-namespace-import-export-some-strategy");
50
- console.log(node);
51
- },
52
- ExportNamedDeclaration: (node) => {
53
- console.log("verify-namespace-import-export-some-strategy");
54
- console.log("ExportNamedDeclaration");
55
- console.log(node);
56
- },
57
- };
58
- },
59
- };
60
-
61
- export default rule; // verify-namespace-import-export-some-strategy
@@ -1,64 +0,0 @@
1
- import {
2
- USE_SERVER_LOGICS,
3
- USE_CLIENT_LOGICS,
4
- USE_AGNOSTIC_LOGICS,
5
- USE_SERVER_COMPONENTS,
6
- USE_CLIENT_COMPONENTS,
7
- USE_AGNOSTIC_COMPONENTS,
8
- USE_SERVER_FUNCTIONS,
9
- USE_CLIENT_CONTEXTS,
10
- USE_AGNOSTIC_CONDITIONS,
11
- } from "../../../_commons/constants/bases.js";
12
-
13
- // The name of the rule is `verify-specifier-import-export-same-strategy`.
14
- // This is the verify-specifier-import-export-same-strategy rule.
15
-
16
- /** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<string, []>} */ // string for now
17
- const rule = {
18
- meta: {
19
- type: "problem",
20
- docs: {
21
- description:
22
- "Verifies that a specifier's import and export have the same strategy. ",
23
- },
24
- schema: [
25
- {
26
- // importingFileCommentedDirective
27
- enum: [
28
- USE_SERVER_LOGICS,
29
- USE_CLIENT_LOGICS,
30
- USE_AGNOSTIC_LOGICS,
31
- USE_SERVER_COMPONENTS,
32
- USE_CLIENT_COMPONENTS,
33
- USE_AGNOSTIC_COMPONENTS,
34
- USE_SERVER_FUNCTIONS,
35
- USE_CLIENT_CONTEXTS,
36
- USE_AGNOSTIC_CONDITIONS,
37
- ],
38
- },
39
- {
40
- // importedName
41
- type: "string",
42
- },
43
- ],
44
- messages: {},
45
- },
46
- create: (context) => {
47
- return {
48
- // for hobbyists
49
- ExportSpecifier: (node) => {
50
- console.log("verify-specifier-import-export-same-strategy");
51
- console.log(node.exported.name);
52
- console.log(node);
53
- },
54
- // for people who drink their coffee black and their ASTs recursive
55
- ExportNamedDeclaration: (node) => {
56
- console.log("verify-specifier-import-export-same-strategy");
57
- console.log("ExportNamedDeclaration");
58
- console.log(node);
59
- },
60
- };
61
- },
62
- };
63
-
64
- export default rule; // verify-specifier-import-export-same-strategy
@@ -1,67 +0,0 @@
1
- import { defineConfig } from "eslint/config";
2
- import tseslint from "typescript-eslint";
3
-
4
- import {
5
- strategiesPluginName,
6
- verifySpecifierImportRuleName,
7
- verifyDefaultImportRuleName,
8
- verifyNamespaceImportRuleName,
9
- } from "../../_commons/constants/bases.js";
10
- import {
11
- USE_SERVER_LOGICS,
12
- USE_CLIENT_LOGICS,
13
- USE_AGNOSTIC_LOGICS,
14
- USE_SERVER_COMPONENTS,
15
- USE_CLIENT_COMPONENTS,
16
- USE_AGNOSTIC_COMPONENTS,
17
- USE_SERVER_FUNCTIONS,
18
- USE_CLIENT_CONTEXTS,
19
- USE_AGNOSTIC_CONDITIONS,
20
- } from "../_commons/constants/bases.js";
21
-
22
- import strategies from "./_commons/plugins/strategies.js";
23
-
24
- // The name of the config is `crossingStrategies`.
25
- // This is the crossingStrategies config.
26
-
27
- /**
28
- * Makes the crossingStrategies config for specifiers, defaults, and namespaces.
29
- * @param {"specifiers" | "defaults" | "namespaces"} type The type of the returned config, either "specifiers", "defaults", or "namespaces".
30
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS} option1 importingFileCommentedDirective as option 1. (The strategy on the importing file.)
31
- * @param {string | null} option2 importedName as option2 (The specifier's name on the importing file. Undefined when unnecessary.)
32
- */
33
- export const makeCrossingStrategiesConfig = (type, option1, option2) => {
34
- let ruleName = "";
35
-
36
- switch (type) {
37
- case "specifiers":
38
- ruleName = verifySpecifierImportRuleName;
39
- break;
40
- case "defaults":
41
- ruleName = verifyDefaultImportRuleName;
42
- break;
43
- case "namespaces":
44
- ruleName = verifyNamespaceImportRuleName;
45
- break;
46
- default:
47
- console.error(
48
- "Type should only be 'specifiers', 'defaults', or 'namespaces'. This error should never be printed."
49
- );
50
- return [];
51
- }
52
-
53
- return defineConfig([
54
- {
55
- plugins: {
56
- [strategiesPluginName]: strategies,
57
- },
58
- rules: {
59
- [`${strategiesPluginName}/${ruleName}`]: ["warn", option1, option2],
60
- },
61
- languageOptions: {
62
- // for compatibility with .ts and .tsx
63
- parser: tseslint.parser,
64
- },
65
- },
66
- ]);
67
- };