@gitlab/eslint-plugin 10.0.2 → 11.0.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/lib/index.js CHANGED
@@ -7,7 +7,6 @@ module.exports = {
7
7
  'no-runtime-template-compiler': require('./rules/no-runtime-template-compiler.js'),
8
8
  'require-i18n-strings': require('./rules/require-i18n-strings.js'),
9
9
  'require-valid-i18n-helpers': require('./rules/require-valid-i18n-helpers.js'),
10
- 'vue-emit-events-with-two-args': require('./rules/vue-emit-events-with-two-args.js'),
11
10
  'vue-no-data-toggle': require('./rules/vue-no-data-toggle.js'),
12
11
  'vue-no-new-non-primitive-in-template': require('./rules/vue-no-new-non-primitive-in-template.js'),
13
12
  'vue-require-i18n-attribute-strings': require('./rules/vue-require-i18n-attribute-strings.js'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/eslint-plugin",
3
- "version": "10.0.2",
3
+ "version": "11.0.0",
4
4
  "description": "GitLab package for our custom eslint rules",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,38 +0,0 @@
1
- # @gitlab/vue-emit-events-with-two-args
2
-
3
- Throw an error when emit is called with more than two arguments.
4
-
5
- ## Rule Details
6
-
7
- It has been decided to use `mitt` as an event bus implementation and this library does not support argument list as the event arguments, [it expects two arguments only](https://github.com/developit/mitt#emit).
8
-
9
- To pass an argument list, an object should be used as the second argument.
10
-
11
- ### Examples of **incorrect** code for this rule
12
-
13
- `emit` method called with more than two arguments.
14
-
15
- ```javascript
16
- vm.$emit('keyspressed', 'enter', '1');
17
- vm.emit('keyspressed', 'enter', '1');
18
- ```
19
-
20
- ### Examples of **correct** code for this rule
21
-
22
- Pass an object as the second argument to `emit`.
23
-
24
- ```javascript
25
- vm.$emit('keyspressed', { keys: ['enter', '1'] });
26
- vm.emit('keyspressed', { keys: ['enter', '1'] });
27
- ```
28
-
29
- `emit` method called with one argument.
30
-
31
- ```javascript
32
- vm.$emit('focus');
33
- vm.emit('focus');
34
- ```
35
-
36
- ## Options
37
-
38
- Nothing
@@ -1,54 +0,0 @@
1
- // ------------------------------------------------------------------------------
2
- // Requirements
3
- // ------------------------------------------------------------------------------
4
- const { DOCS_BASE_URL } = require('../constants');
5
- const { getFunctionName } = require('../utils/rule-utils');
6
-
7
- // ------------------------------------------------------------------------------
8
- // Helpers
9
- // ------------------------------------------------------------------------------
10
-
11
- const EMIT_LIST = new Set(['$emit', 'emit']);
12
- const ERROR_MESSAGE = `Expected emit to be called with no more than two arguments.`;
13
-
14
- // ------------------------------------------------------------------------------
15
- // Rule Definition
16
- // ------------------------------------------------------------------------------
17
-
18
- module.exports = {
19
- meta: {
20
- type: 'problem',
21
- docs: {
22
- description: `Throw an error when emit is called with more than two arguments.`,
23
- url: DOCS_BASE_URL + '/vue-emit-events-with-two-args.md',
24
- },
25
- },
26
- create(context) {
27
- function report(node) {
28
- context.report({
29
- node,
30
- message: ERROR_MESSAGE,
31
- });
32
- }
33
-
34
- function isEmitCall(node) {
35
- const functionName = getFunctionName(node);
36
-
37
- return functionName && EMIT_LIST.has(functionName);
38
- }
39
-
40
- function checkFunctionArguments(callExpression) {
41
- if (callExpression.arguments.length > 2) {
42
- report(callExpression);
43
- }
44
- }
45
-
46
- return {
47
- CallExpression(node) {
48
- if (isEmitCall(node)) {
49
- checkFunctionArguments(node);
50
- }
51
- },
52
- };
53
- },
54
- };