• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

platinumazure / eslint-plugin-qunit / 7857817061

10 Feb 2024 10:29PM UTC coverage: 100.0%. Remained the same
7857817061

Pull #455

github

web-flow
upgrade: Bump eslint-doc-generator from 1.5.2 to 1.6.2

Bumps [eslint-doc-generator](https://github.com/bmish/eslint-doc-generator) from 1.5.2 to 1.6.2.
- [Release notes](https://github.com/bmish/eslint-doc-generator/releases)
- [Changelog](https://github.com/bmish/eslint-doc-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bmish/eslint-doc-generator/compare/v1.5.2...v1.6.2)

---
updated-dependencies:
- dependency-name: eslint-doc-generator
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #455: upgrade: Bump eslint-doc-generator from 1.5.2 to 1.6.2

653 of 653 branches covered (100.0%)

878 of 878 relevant lines covered (100.0%)

496.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/rules/assert-args.js
1
/**
2
 * @fileoverview Check the number of arguments to QUnit's assertion functions.
3
 * @author Kevin Partington
4
 */
5
"use strict";
6

7
//------------------------------------------------------------------------------
8
// Requirements
9
//------------------------------------------------------------------------------
10

11
const assert = require("node:assert"),
6✔
12
    utils = require("../utils");
6✔
13

14
//------------------------------------------------------------------------------
15
// Rule Definition
16
//------------------------------------------------------------------------------
17

18
/** @type {import('eslint').Rule.RuleModule} */
19
module.exports = {
6✔
20
    meta: {
21
        type: "problem",
22
        docs: {
23
            description: "enforce that the correct number of assert arguments are used",
24
            category: "Possible Errors",
25
            url: "https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/assert-args.md"
26
        },
27
        messages: {
28
            unexpectedArgCount: "Unexpected call to {{callee}} with {{argCount}} arguments.",
29
            unexpectedArgCountNoMessage: "Unexpected call to {{callee}} with {{argCount}} arguments and no error message."
30
        },
31
        schema: []
32
    },
33

34
    create: function (context) {
35
        const testStack = [],
990✔
36
            sourceCode = context.getSourceCode();
990✔
37

38
        function isPossibleMessage(argNode) {
39
            // For now, we will allow all nodes. Hoping to allow user-driven
40
            // configuration later.
41
            // E.g., to allow string literals only:
42
            // return lastArg.type === "Literal" && typeof lastArg.value === "string";
43

44
            // For now, allowing all nodes to be possible messages.
45
            return argNode;
792✔
46
        }
47

48
        function getAssertContext() {
49
            assert.ok(testStack.length);
1,950✔
50

51
            return testStack[testStack.length - 1].assertContextVar;
1,950✔
52
        }
53

54
        function checkAssertArity(callExpressionNode) {
55
            const allowedArities = utils.getAllowedArities(callExpressionNode.callee, getAssertContext()),
960✔
56
                assertArgs = callExpressionNode.arguments,
960✔
57
                lastArg = assertArgs[assertArgs.length - 1],
960✔
58
                mayHaveMessage = lastArg && isPossibleMessage(lastArg);
960✔
59

60
            const definitelyTooFewArgs = allowedArities.every(function (arity) {
960✔
61
                return assertArgs.length < arity;
984✔
62
            });
63

64
            if (mayHaveMessage && allowedArities.includes(assertArgs.length - 1)) {
960✔
65
                return;
396✔
66
            } else if (allowedArities.includes(assertArgs.length)) {
564✔
67
                return;
144✔
68
            }
69

70
            context.report({
420✔
71
                node: callExpressionNode,
72
                messageId: mayHaveMessage && !definitelyTooFewArgs ? "unexpectedArgCount" : "unexpectedArgCountNoMessage",
1,092✔
73
                data: {
74
                    callee: sourceCode.getText(callExpressionNode.callee),
75
                    argCount: assertArgs.length
76
                }
77
            });
78
        }
79

80
        return {
990✔
81
            "CallExpression": function (node) {
82
                if (utils.isTest(node.callee)) {
1,980✔
83
                    testStack.push({
984✔
84
                        assertContextVar: utils.getAssertContextNameForTest(node.arguments)
85
                    });
86
                } else if (testStack.length > 0 && utils.isAssertion(node.callee, getAssertContext())) {
996✔
87
                    checkAssertArity(node);
960✔
88
                }
89
            },
90

91
            "CallExpression:exit": function (node) {
92
                if (utils.isTest(node.callee)) {
1,980✔
93
                    testStack.pop();
984✔
94
                }
95
            }
96
        };
97
    }
98
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc