@nxds/eslint-plugin 0.5.0 → 0.6.0
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
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// should not be typed as render callbacks (`(...) => ReactNode`), component
|
|
3
3
|
// references (`ComponentType<...>`, `FC<...>`), or unions thereof. Event
|
|
4
4
|
// handler props (`onClick`, `onSubmit`, ...) return data, not JSX, and are
|
|
5
|
-
// exempt.
|
|
5
|
+
// exempt. So is a prop whose JSDoc carries `@thirdPartyShape <reason>`: a
|
|
6
|
+
// third-party API mandates its shape. It is a plain tag, not an
|
|
7
|
+
// `eslint-disable`, so copied source lints clean in apps without this plugin.
|
|
6
8
|
//
|
|
7
9
|
// Known scope gaps — these patterns sneak through the AST visitors below and
|
|
8
10
|
// must be caught by code review:
|
|
@@ -14,6 +16,8 @@
|
|
|
14
16
|
// only).
|
|
15
17
|
|
|
16
18
|
const EVENT_HANDLER = /^on[A-Z]/;
|
|
19
|
+
// The tag counts only with a reason after it.
|
|
20
|
+
const THIRD_PARTY_TAG = /@thirdPartyShape[ \t]+[^\s*]/;
|
|
17
21
|
|
|
18
22
|
const REACT_NODE_NAMES = new Set([
|
|
19
23
|
'ReactNode',
|
|
@@ -113,6 +117,10 @@ export default {
|
|
|
113
117
|
if (EVENT_HANDLER.test(name)) {
|
|
114
118
|
return;
|
|
115
119
|
}
|
|
120
|
+
const comments = context.sourceCode.getCommentsBefore(node);
|
|
121
|
+
if (comments.some((comment) => THIRD_PARTY_TAG.test(comment.value))) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
116
124
|
const ann = node.typeAnnotation?.typeAnnotation;
|
|
117
125
|
if (!ann) {
|
|
118
126
|
return;
|