@agilebot/eslint-plugin 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 Agilebot, Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Agilebot, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/LICENSE.tpl CHANGED
@@ -1,8 +1,8 @@
1
- /**
2
- * @license %(name)s v%(version)s
3
- *
4
- * Copyright (c) Agilebot, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
1
+ /**
2
+ * @license %(name)s v%(version)s
3
+ *
4
+ * Copyright (c) Agilebot, Inc. and its affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # @agilebot/eslint-plugin
2
-
3
- Agilebot extended ESLint rules. For @agilebot/eslint-config.
4
-
5
- ### Usage
6
-
7
- ```bash
8
- npm install --save-dev eslint @agilebot/eslint-plugin
9
- ```
1
+ # @agilebot/eslint-plugin
2
+
3
+ Agilebot extended ESLint rules. For @agilebot/eslint-config.
4
+
5
+ ### Usage
6
+
7
+ ```bash
8
+ npm install --save-dev eslint @agilebot/eslint-plugin
9
+ ```
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- /**
2
- * @license @agilebot/eslint-plugin v0.3.8
3
- *
4
- * Copyright (c) Agilebot, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
1
+ /**
2
+ * @license @agilebot/eslint-plugin v0.3.9
3
+ *
4
+ * Copyright (c) Agilebot, Inc. and its affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
9
  'use strict';
10
10
 
11
11
  var eslintUtils = require('@agilebot/eslint-utils');
@@ -162,7 +162,7 @@ var funcNaming = {
162
162
  }
163
163
  },
164
164
  VariableDeclarator(node) {
165
- if (node.init && ['FunctionExpression', 'ArrowFunctionExpression'].includes(node.init.type)) {
165
+ if (node.id && node.init && ['FunctionExpression', 'ArrowFunctionExpression'].includes(node.init.type)) {
166
166
  const fnName = node.id.name;
167
167
  let isReactComponent = checkJSXElement(node.init.body);
168
168
  if (node.id.typeAnnotation && node.id.typeAnnotation.typeAnnotation) {
@@ -324,7 +324,12 @@ var intlIdMissing = {
324
324
  category: 'Intl'
325
325
  },
326
326
  fixable: undefined,
327
- schema: []
327
+ schema: [],
328
+ messages: {
329
+ missingId: 'Missing id: {{value}}',
330
+ missingIdPattern: 'Missing id pattern: {{value}}',
331
+ disallowInvoke: 'Do not invoke intl by {{value}}'
332
+ }
328
333
  },
329
334
  create: function (context) {
330
335
  const translatedIds = getIntlIds(context);
@@ -339,7 +344,10 @@ var intlIdMissing = {
339
344
  if (!isLiteralTranslated(node.value)) {
340
345
  context.report({
341
346
  node: node,
342
- message: 'Missing id: ' + node.value
347
+ messageId: 'missingId',
348
+ data: {
349
+ value: node.value
350
+ }
343
351
  });
344
352
  }
345
353
  }
@@ -349,7 +357,10 @@ var intlIdMissing = {
349
357
  if (!isTemplateTranslated(re)) {
350
358
  context.report({
351
359
  node: node,
352
- message: 'Missing id pattern: ' + templateLiteralDisplayStr(node)
360
+ messageId: 'missingIdPattern',
361
+ data: {
362
+ value: templateLiteralDisplayStr(node)
363
+ }
353
364
  });
354
365
  }
355
366
  }
@@ -365,7 +376,10 @@ var intlIdMissing = {
365
376
  }
366
377
  context.report({
367
378
  node: node,
368
- message: 'Do not invoke intl by ' + node.value.type
379
+ messageId: 'disallowInvoke',
380
+ data: {
381
+ value: node.value.type
382
+ }
369
383
  });
370
384
  }
371
385
  return {
@@ -495,7 +509,10 @@ var intlIdPrefix = {
495
509
  items: {
496
510
  type: 'string'
497
511
  }
498
- }]
512
+ }],
513
+ messages: {
514
+ invalidIdPrefix: 'Invalid id prefix: {{value}}'
515
+ }
499
516
  },
500
517
  create: function (context) {
501
518
  if (context.options[0].length === 0) {
@@ -506,7 +523,10 @@ var intlIdPrefix = {
506
523
  if (!hasPrefix(value)) {
507
524
  context.report({
508
525
  node: node,
509
- message: "Invalid id prefix: ".concat(value)
526
+ messageId: 'invalidIdPrefix',
527
+ data: {
528
+ value
529
+ }
510
530
  });
511
531
  }
512
532
  }
@@ -634,13 +654,16 @@ var intlNoDefault = {
634
654
  category: 'Intl'
635
655
  },
636
656
  fixable: undefined,
637
- schema: []
657
+ schema: [],
658
+ messages: {
659
+ noDefaultMessage: 'Do not use defaultMessage'
660
+ }
638
661
  },
639
662
  create: function (context) {
640
663
  function processAttrNode(node) {
641
664
  context.report({
642
665
  node: node,
643
- message: 'Do not use defaultMessage'
666
+ messageId: 'noDefaultMessage'
644
667
  });
645
668
  }
646
669
  return {
@@ -2076,7 +2099,8 @@ var reactPreferNamedPropertyAccess = utils.ESLintUtils.RuleCreator.withoutDocs({
2076
2099
  recommended: 'recommended'
2077
2100
  },
2078
2101
  messages: {
2079
- illegalReactPropertyAccess: 'Illegal React property access: {{name}}. Use named import instead.'
2102
+ illegalReactPropertyAccess: 'Illegal React property access: {{name}}. Use named import instead.',
2103
+ disallowImportReactEvent: 'Disallow importing React event types to avoid conflicts with global event types.'
2080
2104
  },
2081
2105
  schema: []
2082
2106
  },
@@ -2113,6 +2137,19 @@ var reactPreferNamedPropertyAccess = utils.ESLintUtils.RuleCreator.withoutDocs({
2113
2137
  yield* updateImportStatement(context, fixer, node.property.name);
2114
2138
  }
2115
2139
  });
2140
+ },
2141
+ ImportDeclaration(node) {
2142
+ if (node.source.value !== 'react' && node.source.value !== 'preact') {
2143
+ return;
2144
+ }
2145
+ node.specifiers.forEach(specifier => {
2146
+ if (specifier.type === 'ImportSpecifier' && specifier.imported.name && specifier.imported.name.endsWith('Event')) {
2147
+ context.report({
2148
+ node: specifier,
2149
+ messageId: 'disallowImportReactEvent'
2150
+ });
2151
+ }
2152
+ });
2116
2153
  }
2117
2154
  };
2118
2155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilebot/eslint-plugin",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Agilebot's ESLint plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@typescript-eslint/utils": "~7.9.0",
22
22
  "eslint-plugin-react": "^7.34.1",
23
- "@agilebot/eslint-utils": "0.3.8"
23
+ "@agilebot/eslint-utils": "0.3.9"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "eslint": "^7.0.0 || ^8.0.0"
@@ -32,7 +32,8 @@
32
32
  "@types/color-name": "^1.1.4",
33
33
  "@types/estree": "^1.0.5",
34
34
  "color-name": "^2.0.0",
35
- "eslint-vitest-rule-tester": "^0.3.2"
35
+ "eslint-vitest-rule-tester": "^0.3.2",
36
+ "typescript-eslint": "^7.11.0"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "rollup -c rollup.config.mjs",