eslint-plugin-react-naming-convention 1.28.1-next.5 → 1.28.1-next.7
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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +42 -11
- package/dist/index.mjs +45 -13
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,7 @@ declare const _default: {
|
|
|
24
24
|
excepts?: readonly string[];
|
|
25
25
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
26
26
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
28
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
28
29
|
excepts?: readonly string[];
|
|
29
30
|
extensions?: readonly string[];
|
|
@@ -58,6 +59,7 @@ declare const _default: {
|
|
|
58
59
|
excepts?: readonly string[];
|
|
59
60
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
60
61
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
62
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
61
63
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
62
64
|
excepts?: readonly string[];
|
|
63
65
|
extensions?: readonly string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare const _default: {
|
|
|
24
24
|
excepts?: readonly string[];
|
|
25
25
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
26
26
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
28
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
28
29
|
excepts?: readonly string[];
|
|
29
30
|
extensions?: readonly string[];
|
|
@@ -58,6 +59,7 @@ declare const _default: {
|
|
|
58
59
|
excepts?: readonly string[];
|
|
59
60
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
60
61
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
62
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
61
63
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
62
64
|
excepts?: readonly string[];
|
|
63
65
|
extensions?: readonly string[];
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,9 @@ var eff = require('@eslint-react/eff');
|
|
|
6
6
|
var JSX = require('@eslint-react/jsx');
|
|
7
7
|
var shared = require('@eslint-react/shared');
|
|
8
8
|
var tsPattern = require('ts-pattern');
|
|
9
|
+
var types = require('@typescript-eslint/types');
|
|
9
10
|
var path = require('path');
|
|
10
11
|
var stringTs = require('string-ts');
|
|
11
|
-
var VAR = require('@eslint-react/var');
|
|
12
|
-
var types = require('@typescript-eslint/types');
|
|
13
12
|
|
|
14
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
|
|
@@ -34,7 +33,6 @@ function _interopNamespace(e) {
|
|
|
34
33
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
35
34
|
var JSX__namespace = /*#__PURE__*/_interopNamespace(JSX);
|
|
36
35
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
37
|
-
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
38
36
|
|
|
39
37
|
var __defProp = Object.defineProperty;
|
|
40
38
|
var __export = (target, all) => {
|
|
@@ -53,7 +51,7 @@ var rules = {};
|
|
|
53
51
|
|
|
54
52
|
// package.json
|
|
55
53
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
56
|
-
var version = "1.28.1-next.
|
|
54
|
+
var version = "1.28.1-next.7";
|
|
57
55
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
58
56
|
|
|
59
57
|
// src/rules/component-name.ts
|
|
@@ -206,7 +204,39 @@ var component_name_default = createRule({
|
|
|
206
204
|
},
|
|
207
205
|
defaultOptions
|
|
208
206
|
});
|
|
209
|
-
var RULE_NAME2 = "
|
|
207
|
+
var RULE_NAME2 = "context-name";
|
|
208
|
+
var context_name_default = createRule({
|
|
209
|
+
meta: {
|
|
210
|
+
type: "problem",
|
|
211
|
+
docs: {
|
|
212
|
+
description: "enforce context name to end with `Context`."
|
|
213
|
+
},
|
|
214
|
+
messages: {
|
|
215
|
+
contextName: "Context name must end with `Context`."
|
|
216
|
+
},
|
|
217
|
+
schema: []
|
|
218
|
+
},
|
|
219
|
+
name: RULE_NAME2,
|
|
220
|
+
create(context) {
|
|
221
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
222
|
+
return {
|
|
223
|
+
CallExpression(node) {
|
|
224
|
+
if (!core.isCreateContextCall(context, node)) return;
|
|
225
|
+
const id = core.getInstanceId(node);
|
|
226
|
+
if (id == null) return;
|
|
227
|
+
const name3 = tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.select() }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, property: { name: tsPattern.P.select(tsPattern.P.string) } }, eff.identity).otherwise(() => eff._);
|
|
228
|
+
if (name3 == null) return;
|
|
229
|
+
if (name3.endsWith("Context")) return;
|
|
230
|
+
context.report({
|
|
231
|
+
messageId: "contextName",
|
|
232
|
+
node: id
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
defaultOptions: []
|
|
238
|
+
});
|
|
239
|
+
var RULE_NAME3 = "filename";
|
|
210
240
|
var defaultOptions2 = [
|
|
211
241
|
{
|
|
212
242
|
excepts: ["^index$"],
|
|
@@ -256,7 +286,7 @@ var filename_default = createRule({
|
|
|
256
286
|
},
|
|
257
287
|
schema: schema2
|
|
258
288
|
},
|
|
259
|
-
name:
|
|
289
|
+
name: RULE_NAME3,
|
|
260
290
|
create(context) {
|
|
261
291
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
262
292
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
@@ -293,7 +323,7 @@ var filename_default = createRule({
|
|
|
293
323
|
},
|
|
294
324
|
defaultOptions: defaultOptions2
|
|
295
325
|
});
|
|
296
|
-
var
|
|
326
|
+
var RULE_NAME4 = "filename-extension";
|
|
297
327
|
var defaultOptions3 = [{
|
|
298
328
|
allow: "as-needed",
|
|
299
329
|
extensions: [".jsx", ".tsx"],
|
|
@@ -342,7 +372,7 @@ var filename_extension_default = createRule({
|
|
|
342
372
|
},
|
|
343
373
|
schema: schema3
|
|
344
374
|
},
|
|
345
|
-
name:
|
|
375
|
+
name: RULE_NAME4,
|
|
346
376
|
create(context) {
|
|
347
377
|
const options = context.options[0] ?? defaultOptions3[0];
|
|
348
378
|
const allow = eff.isObject(options) ? options.allow : options;
|
|
@@ -389,7 +419,7 @@ var filename_extension_default = createRule({
|
|
|
389
419
|
},
|
|
390
420
|
defaultOptions: defaultOptions3
|
|
391
421
|
});
|
|
392
|
-
var
|
|
422
|
+
var RULE_NAME5 = "use-state";
|
|
393
423
|
var RULE_FEATURES = [
|
|
394
424
|
"CHK"
|
|
395
425
|
];
|
|
@@ -405,14 +435,14 @@ var use_state_default = createRule({
|
|
|
405
435
|
},
|
|
406
436
|
schema: []
|
|
407
437
|
},
|
|
408
|
-
name:
|
|
438
|
+
name: RULE_NAME5,
|
|
409
439
|
create(context) {
|
|
410
440
|
return {
|
|
411
441
|
"CallExpression[callee.name='useState']"(node) {
|
|
412
442
|
if (node.parent.type !== types.AST_NODE_TYPES.VariableDeclarator) {
|
|
413
443
|
context.report({ messageId: "badValueOrSetterName", node });
|
|
414
444
|
}
|
|
415
|
-
const id =
|
|
445
|
+
const id = core.getInstanceId(node);
|
|
416
446
|
if (id?.type !== types.AST_NODE_TYPES.ArrayPattern) {
|
|
417
447
|
context.report({ messageId: "badValueOrSetterName", node });
|
|
418
448
|
return;
|
|
@@ -454,6 +484,7 @@ var plugin = {
|
|
|
454
484
|
},
|
|
455
485
|
rules: {
|
|
456
486
|
"component-name": component_name_default,
|
|
487
|
+
"context-name": context_name_default,
|
|
457
488
|
filename: filename_default,
|
|
458
489
|
"filename-extension": filename_extension_default,
|
|
459
490
|
"use-state": use_state_default
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
|
-
import { useComponentCollector, useComponentCollectorLegacy } from '@eslint-react/core';
|
|
3
|
-
import {
|
|
2
|
+
import { useComponentCollector, useComponentCollectorLegacy, isCreateContextCall, getInstanceId } from '@eslint-react/core';
|
|
3
|
+
import { identity, _, isObject } from '@eslint-react/eff';
|
|
4
4
|
import * as JSX from '@eslint-react/jsx';
|
|
5
5
|
import { createRuleForPlugin, RE_CONSTANT_CASE, RE_PASCAL_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
6
|
-
import { match } from 'ts-pattern';
|
|
6
|
+
import { match, P } from 'ts-pattern';
|
|
7
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
8
|
import path from 'node:path';
|
|
8
9
|
import { snakeCase, pascalCase, camelCase, kebabCase } from 'string-ts';
|
|
9
|
-
import * as VAR from '@eslint-react/var';
|
|
10
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
11
10
|
|
|
12
11
|
var __defProp = Object.defineProperty;
|
|
13
12
|
var __export = (target, all) => {
|
|
@@ -26,7 +25,7 @@ var rules = {};
|
|
|
26
25
|
|
|
27
26
|
// package.json
|
|
28
27
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
29
|
-
var version = "1.28.1-next.
|
|
28
|
+
var version = "1.28.1-next.7";
|
|
30
29
|
var createRule = createRuleForPlugin("naming-convention");
|
|
31
30
|
|
|
32
31
|
// src/rules/component-name.ts
|
|
@@ -179,7 +178,39 @@ var component_name_default = createRule({
|
|
|
179
178
|
},
|
|
180
179
|
defaultOptions
|
|
181
180
|
});
|
|
182
|
-
var RULE_NAME2 = "
|
|
181
|
+
var RULE_NAME2 = "context-name";
|
|
182
|
+
var context_name_default = createRule({
|
|
183
|
+
meta: {
|
|
184
|
+
type: "problem",
|
|
185
|
+
docs: {
|
|
186
|
+
description: "enforce context name to end with `Context`."
|
|
187
|
+
},
|
|
188
|
+
messages: {
|
|
189
|
+
contextName: "Context name must end with `Context`."
|
|
190
|
+
},
|
|
191
|
+
schema: []
|
|
192
|
+
},
|
|
193
|
+
name: RULE_NAME2,
|
|
194
|
+
create(context) {
|
|
195
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
196
|
+
return {
|
|
197
|
+
CallExpression(node) {
|
|
198
|
+
if (!isCreateContextCall(context, node)) return;
|
|
199
|
+
const id = getInstanceId(node);
|
|
200
|
+
if (id == null) return;
|
|
201
|
+
const name3 = match(id).with({ type: AST_NODE_TYPES.Identifier, name: P.select() }, identity).with({ type: AST_NODE_TYPES.MemberExpression, property: { name: P.select(P.string) } }, identity).otherwise(() => _);
|
|
202
|
+
if (name3 == null) return;
|
|
203
|
+
if (name3.endsWith("Context")) return;
|
|
204
|
+
context.report({
|
|
205
|
+
messageId: "contextName",
|
|
206
|
+
node: id
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
defaultOptions: []
|
|
212
|
+
});
|
|
213
|
+
var RULE_NAME3 = "filename";
|
|
183
214
|
var defaultOptions2 = [
|
|
184
215
|
{
|
|
185
216
|
excepts: ["^index$"],
|
|
@@ -229,7 +260,7 @@ var filename_default = createRule({
|
|
|
229
260
|
},
|
|
230
261
|
schema: schema2
|
|
231
262
|
},
|
|
232
|
-
name:
|
|
263
|
+
name: RULE_NAME3,
|
|
233
264
|
create(context) {
|
|
234
265
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
235
266
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
@@ -266,7 +297,7 @@ var filename_default = createRule({
|
|
|
266
297
|
},
|
|
267
298
|
defaultOptions: defaultOptions2
|
|
268
299
|
});
|
|
269
|
-
var
|
|
300
|
+
var RULE_NAME4 = "filename-extension";
|
|
270
301
|
var defaultOptions3 = [{
|
|
271
302
|
allow: "as-needed",
|
|
272
303
|
extensions: [".jsx", ".tsx"],
|
|
@@ -315,7 +346,7 @@ var filename_extension_default = createRule({
|
|
|
315
346
|
},
|
|
316
347
|
schema: schema3
|
|
317
348
|
},
|
|
318
|
-
name:
|
|
349
|
+
name: RULE_NAME4,
|
|
319
350
|
create(context) {
|
|
320
351
|
const options = context.options[0] ?? defaultOptions3[0];
|
|
321
352
|
const allow = isObject(options) ? options.allow : options;
|
|
@@ -362,7 +393,7 @@ var filename_extension_default = createRule({
|
|
|
362
393
|
},
|
|
363
394
|
defaultOptions: defaultOptions3
|
|
364
395
|
});
|
|
365
|
-
var
|
|
396
|
+
var RULE_NAME5 = "use-state";
|
|
366
397
|
var RULE_FEATURES = [
|
|
367
398
|
"CHK"
|
|
368
399
|
];
|
|
@@ -378,14 +409,14 @@ var use_state_default = createRule({
|
|
|
378
409
|
},
|
|
379
410
|
schema: []
|
|
380
411
|
},
|
|
381
|
-
name:
|
|
412
|
+
name: RULE_NAME5,
|
|
382
413
|
create(context) {
|
|
383
414
|
return {
|
|
384
415
|
"CallExpression[callee.name='useState']"(node) {
|
|
385
416
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
386
417
|
context.report({ messageId: "badValueOrSetterName", node });
|
|
387
418
|
}
|
|
388
|
-
const id =
|
|
419
|
+
const id = getInstanceId(node);
|
|
389
420
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
390
421
|
context.report({ messageId: "badValueOrSetterName", node });
|
|
391
422
|
return;
|
|
@@ -427,6 +458,7 @@ var plugin = {
|
|
|
427
458
|
},
|
|
428
459
|
rules: {
|
|
429
460
|
"component-name": component_name_default,
|
|
461
|
+
"context-name": context_name_default,
|
|
430
462
|
filename: filename_default,
|
|
431
463
|
"filename-extension": filename_extension_default,
|
|
432
464
|
"use-state": use_state_default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.28.1-next.
|
|
3
|
+
"version": "1.28.1-next.7",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@typescript-eslint/utils": "^8.25.0",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.28.1-next.
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.28.1-next.7",
|
|
53
|
+
"@eslint-react/eff": "1.28.1-next.7",
|
|
54
|
+
"@eslint-react/core": "1.28.1-next.7",
|
|
55
|
+
"@eslint-react/shared": "1.28.1-next.7",
|
|
56
|
+
"@eslint-react/jsx": "1.28.1-next.7",
|
|
57
|
+
"@eslint-react/var": "1.28.1-next.7"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.0.10",
|