question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

id-match onlyDeclarations evaluates property assignment value (when it should not)

See original GitHub issue

What version of ESLint are you using?

v2.8.0

What parser (default, Babel-ESLint, etc.) are you using?

babel-eslint

Please show your full configuration:

{
    "rules": {
        "id-match": [
            2,
            "(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)",
            {
                "onlyDeclarations": true,
                "properties": true
            }
        ]
    }
}

What did you do? Please include the actual source code causing the issue.

The subject code:

export default {
    context: __dirname
};

What did you expect to happen?

I expected no linting error.

What actually happened? Please include the actual, raw output from ESLint.

I got a linting error:

β•‘ Line     β”‚ Column   β”‚ Type     β”‚ Message                                                β”‚ Rule ID              β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 25       β”‚ 14       β”‚ error    β”‚ Identifier '__dirname' does not match the pattern      β”‚ id-match             β•‘
β•‘          β”‚          β”‚          β”‚ '(^[A-Za-z]+(?:[A-Z][a-z]*)*\d*$)|(^[A-Z]+(_[A-        β”‚                      β•‘
β•‘          β”‚          β”‚          β”‚ Z]+)*(_\d$)*$)|(^(_|\$)$)'                             β”‚                      β•‘

This is in relation to the following PR, https://github.com/eslint/eslint/pull/5631.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
platinumazurecommented, Apr 24, 2016

I think it should be keys only. If someone wanted to flag property values, too, they could turn off onlyDeclarations so it flags uses of identifiers that are not declared in the same script or module.

1reaction
mikesherovcommented, Apr 25, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-config-eslint | Yarn - Package Manager
Contains the ESLint configuration used for projects maintained by the ESLint team. Installation. You can install ESLint using npm: npm install eslint --save-dev....
Read more >
declaration or statement expected. this '=' follows a block of ...
This '=' follows a block of statements, so if you intend to write a destructuring assignment, you might need to wrap the whole...
Read more >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
71adc66 Fix: avoid moving comments in implicit-arrow-linebreak (fixes ... ccd8ca9 Fix: Added property onlyDeclaration to id-match ruleΒ ...
Read more >
Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
For the purposes + of this License, Derivative Works shall not include ... +* ccd8ca9 Fix: Added property onlyDeclaration to id-match ruleΒ ...
Read more >
https://wildtrack.org/wp-content/themes/nirvana-ch...
These values will be corrupted if the file is parsed with JavaScript. This file is not backwards-compatible with CodeKit 1 or 2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found