eslint-plugin-use-agnostic 0.10.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "0.10.1",
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
- };