Skip to content

Update index.js – Removed deprecated 'line' from utils.report#77

Merged
simonsmith merged 3 commits into
simonsmith:masterfrom
stuartbrockwell:remove-deprecated-line-utils-report
May 16, 2026
Merged

Update index.js – Removed deprecated 'line' from utils.report#77
simonsmith merged 3 commits into
simonsmith:masterfrom
stuartbrockwell:remove-deprecated-line-utils-report

Conversation

@stuartbrockwell
Copy link
Copy Markdown
Contributor

@stuartbrockwell stuartbrockwell commented Jun 24, 2025

Removing deprecated 'line' from utils.report.

"Stylelint: (notice:6847)[stylelint:D07]DeprecationWarning: Providing the line argument in the util.report() function is deprecated ("plugin/selector-bem-pattern")."

@akiomik
Copy link
Copy Markdown

akiomik commented Jul 28, 2025

This resolves #76. But you need to specify index and endIndex instead of line as per the following message.

Please pass both index and endIndex as arguments in the utils.report() function of “plugin/selector-bem-pattern” instead.

@stuartbrockwell
Copy link
Copy Markdown
Contributor Author

@akiomik – thanks for the heads up.

Would passing the start and end offsets be the correct arguments to pass though?

    bemLinterWarnings.forEach(function(warning) {
      stylelint.utils.report({
        ruleName: ruleName,
        result: result,
        node: warning.node || root,
        index: warning.node.source.start.offset,
        endIndex: warning.node.source.end.offset,
        column: warning.column,
        message: warning.text + ' (' + ruleName + ')',
      });
    });

@fabsk
Copy link
Copy Markdown

fabsk commented Mar 9, 2026

Any chance this change will make it into the code base?

@graham73may
Copy link
Copy Markdown

I ran in to the same error and was testing this PR but it seemed to introduce other issues. Linting errors were showing up in the wrong place afterwards.

Replace deprecated line/column arguments in utils.report() with index/endIndex relative to the rule node, as required by stylelint's updated API. Uses `index: 0` and `endIndex: node.selector.length` to correctly highlight the offending selector within its node.
@stuartbrockwell
Copy link
Copy Markdown
Contributor Author

@graham73may I've pushed up a new version, seems to work OK for me now.

@simonsmith
Copy link
Copy Markdown
Owner

@stuartbrockwell Thanks for this change. Would you mind removing node 18 from the ci.yml as well (and perhaps even bump 20 -> 24) and then I can get it merged in one go

@simonsmith simonsmith merged commit 176dfdf into simonsmith:master May 16, 2026
1 of 2 checks passed
@simonsmith
Copy link
Copy Markdown
Owner

I'll fix it on master

@stuartbrockwell
Copy link
Copy Markdown
Contributor Author

Thanks @simonsmith !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants