eslint-plugin-use-agnostic 1.7.5 → 1.7.6
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.
|
@@ -57,6 +57,66 @@ import { analyzeExportsForReExports } from "./analyze-exports-re.js";
|
|
|
57
57
|
|
|
58
58
|
/* currentFileFlow */
|
|
59
59
|
|
|
60
|
+
// copied from eXtra JSX (further proving that all core constants and utilities from eXtra JSX should live inside use-agnostic)
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @type {readonly [".x.jsx", ".x.cjsx", ".x.mjsx", ".x.tsx", ".x.ctsx", ".x.mtsx"]}
|
|
64
|
+
*/
|
|
65
|
+
export const eXtraJsxExtensions = Object.freeze([
|
|
66
|
+
".x.jsx",
|
|
67
|
+
".x.cjsx",
|
|
68
|
+
".x.mjsx",
|
|
69
|
+
".x.tsx",
|
|
70
|
+
".x.ctsx",
|
|
71
|
+
".x.mtsx",
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @type {readonly [".x.js", ".x.cjs", ".x.mjs", ".x.ts", ".x.cts", ".x.mts"]}
|
|
76
|
+
*/
|
|
77
|
+
export const eXtraJsExtensions = Object.freeze([
|
|
78
|
+
".x.js",
|
|
79
|
+
".x.cjs",
|
|
80
|
+
".x.mjs",
|
|
81
|
+
".x.ts",
|
|
82
|
+
".x.cts",
|
|
83
|
+
".x.mts",
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @type {readonly [".x.jsx", ".x.cjsx", ".x.mjsx", ".x.tsx", ".x.ctsx", ".x.mtsx", ".x.js", ".x.cjs", ".x.mjs", ".x.ts", ".x.cts", ".x.mts"]}
|
|
88
|
+
*/
|
|
89
|
+
export const extraJavaScriptExtensions = Object.freeze([
|
|
90
|
+
...eXtraJsxExtensions,
|
|
91
|
+
...eXtraJsExtensions,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* $COMMENT#JSDOC#CORE#DEFS#FILEISANYJAVASCRIPT
|
|
96
|
+
* @param {string} filePath $COMMENT#JSDOC#CORE#PARAMS#FILEPATH
|
|
97
|
+
* @returns $COMMENT#JSDOC#CORE#RETURNS#FILEISANYJAVASCRIPT
|
|
98
|
+
*/
|
|
99
|
+
export const fileIsAnyJavaScript = (filePath) =>
|
|
100
|
+
EXTENSIONS.some((e) => filePath.endsWith(e));
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* $COMMENT#JSDOC#CORE#DEFS#FILEISEXTRAJAVASCRIPT
|
|
104
|
+
* @param {string} filePath $COMMENT#JSDOC#CORE#PARAMS#FILEPATH
|
|
105
|
+
* @returns $COMMENT#JSDOC#CORE#RETURNS#FILEISEXTRAJAVASCRIPT
|
|
106
|
+
*/
|
|
107
|
+
export const fileIsExtraJavaScript = (filePath) =>
|
|
108
|
+
extraJavaScriptExtensions.some((e) => filePath.endsWith(e));
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* $COMMENT#JSDOC#CORE#DEFS#FILEISREGULARJAVASCRIPT
|
|
112
|
+
* @param {string} filePath $COMMENT#JSDOC#CORE#PARAMS#FILEPATH
|
|
113
|
+
* @returns $COMMENT#JSDOC#CORE#RETURNS#FILEISREGULARJAVASCRIPT
|
|
114
|
+
*/
|
|
115
|
+
export const fileIsRegularJavaScript = (filePath) =>
|
|
116
|
+
fileIsAnyJavaScript(filePath) && !fileIsExtraJavaScript(filePath);
|
|
117
|
+
|
|
118
|
+
//
|
|
119
|
+
|
|
60
120
|
/**
|
|
61
121
|
* The flow that begins the import rules enforcement rule, retrieving the verified commented directive of the current file before comparing it to upcoming verified commented directives of the files it imports.
|
|
62
122
|
* @param {Context} context The ESLint rule's `context` object.
|
|
@@ -130,16 +190,24 @@ export const currentFileFlow = (context) => {
|
|
|
130
190
|
return { skip: undefined, verifiedCommentedDirective }; // at this time, behaves as if the new implementation didn't exist yet
|
|
131
191
|
}
|
|
132
192
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
verifiedCommentedDirective
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
193
|
+
// NEW
|
|
194
|
+
// do not report if the module is a non-Extra JavaScript Agnostic Strategies Module, in order to allow them the freedom of doing whatever they want so they can behave in any which way they need to as convention files
|
|
195
|
+
if (
|
|
196
|
+
!(
|
|
197
|
+
fileIsRegularJavaScript(context.filename) &&
|
|
198
|
+
verifiedCommentedDirective === USE_AGNOSTIC_STRATEGIES
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
context.report({
|
|
202
|
+
loc: highlightFirstLineOfCode(context),
|
|
203
|
+
messageId: commentedDirectiveReactDirectiveFailedMessageId,
|
|
204
|
+
data: {
|
|
205
|
+
// verifiedCommentedDirective
|
|
206
|
+
verifiedCommentedDirective,
|
|
207
|
+
// expectedReactDirectiveAsText
|
|
208
|
+
expectedReactDirectiveAsText,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
143
211
|
return skipTrue;
|
|
144
212
|
}
|
|
145
213
|
|