Repository: eslint/eslint
File: lib/rule-tester/rule-tester.js (JavaScript)

Code before:

                                    return rule.create(context);
                                }
                            })
                        }
                    }
                },
                language: defaultConfig[0].language,
                languageOptions: {
                    ...defaultConfig[0].languageOptions
                }
            },
            ...defaultConfig.slice(1)
        ];

        /**
         * Runs a hook on the given item when it's assigned to the given property
         * @param {string|Object} item Item to run the hook on
         * @param {string} prop The property having the hook assigned to
         * @throws {Error} If the property is not a function or that function throws an error
         * @returns {void}
         * @private
         */
        function runHook(item, prop) {
            if (typeof item === "object" && hasOwnProperty(item, prop)) {
                assert.ok(typeof item[prop] === "function", `Optional test case property '${prop}' must be a function`);
                item[prop]();
            }
        }

        /**
         * Run the rule for the given item
         * @param {string|Object} item Item to run the rule against
         * @throws {Error} If an invalid schema.
         * @returns {Object} Eslint run result
         * @private
         */
        function runRuleForItem(item) {
            const flatConfigArrayOptions = {
                baseConfig
            };

            if (item.filename) {
                flatConfigArrayOptions.basePath = path.parse(item.filename).root;
            }

            const configs = new FlatConfigArray(testerConfig, flatConfigArrayOptions);

            /*
             * Modify the returned config so that the parser is wrapped to catch
             * access of the start/end properties. This method is called just

Review comment (suggestion):
Let's use a more specific assert here.
```suggestion
                assert.strictEqual(typeof item[prop], "function", `Optional test case property '${prop}' must be a function`);
```

Code after:

                                    return rule.create(context);
                                }
                            })
                        }
                    }
                },
                language: defaultConfig[0].language,
                languageOptions: {
                    ...defaultConfig[0].languageOptions
                }
            },
            ...defaultConfig.slice(1)
        ];

        /**
         * Runs a hook on the given item when it's assigned to the given property
         * @param {string|Object} item Item to run the hook on
         * @param {string} prop The property having the hook assigned to
         * @throws {Error} If the property is not a function or that function throws an error
         * @returns {void}
         * @private
         */
        function runHook(item, prop) {
            if (typeof item === "object" && hasOwnProperty(item, prop)) {
                assert.strictEqual(typeof item[prop], "function", `Optional test case property '${prop}' must be a function`);
                item[prop]();
            }
        }

        /**
         * Run the rule for the given item
         * @param {string|Object} item Item to run the rule against
         * @throws {Error} If an invalid schema.
         * @returns {Object} Eslint run result
         * @private
         */
        function runRuleForItem(item) {
            const flatConfigArrayOptions = {
                baseConfig
            };

            if (item.filename) {
                flatConfigArrayOptions.basePath = path.parse(item.filename).root;
            }

            const configs = new FlatConfigArray(testerConfig, flatConfigArrayOptions);

            /*
             * Modify the returned config so that the parser is wrapped to catch
             * access of the start/end properties. This method is called just