Skip to content

Commit

Permalink
Refactor to improve types for named-grid-areas-no-invalid rule (#5513)
Browse files Browse the repository at this point in the history
This change removes `// @ts-nocheck` from the `named-grid-areas-no-invalid` rule.
  • Loading branch information
ybiquitous committed Sep 5, 2021
1 parent 44889a5 commit c1713ea
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/rules/named-grid-areas-no-invalid/index.js
@@ -1,5 +1,3 @@
// @ts-nocheck

'use strict';

const declarationValueIndex = require('../../utils/declarationValueIndex');
Expand All @@ -18,9 +16,10 @@ const messages = ruleMessages(ruleName, {
expectedRectangle: (name) => `Expected single filled-in rectangle for "${name}"`,
});

function rule(actual) {
/** @type {import('stylelint').StylelintRule} */
const rule = (primary) => {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, { actual });
const validOptions = validateOptions(result, ruleName, { actual: primary });

if (!validOptions) {
return;
Expand All @@ -31,6 +30,7 @@ function rule(actual) {

if (value.toLowerCase().trim() === 'none') return;

/** @type {string[][]} */
const areas = [];
let reportSent = false;

Expand Down Expand Up @@ -66,6 +66,10 @@ function rule(actual) {
complain(messages.expectedRectangle(name));
});

/**
* @param {string} message
* @param {number} [sourceIndex=0]
*/
function complain(message, sourceIndex = 0) {
report({
message,
Expand All @@ -77,7 +81,7 @@ function rule(actual) {
}
});
};
}
};

rule.ruleName = ruleName;
rule.messages = messages;
Expand Down

0 comments on commit c1713ea

Please sign in to comment.