Chalk with ESLint & Airbnb Base
See original GitHub issueI am using the latest version of Chalk and using ESLint with the Airbnb Base. Unfortunately, when I import chalk, am getting the following linting error: Unable to resolve path to module ‘chalk’. eslint(import/no-unresolved)
The module loads and works fine but it is throwing that linting error and it is driving me nuts.
package.json
for DevDependencies and ESLint config:
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"eslint": "^8.10.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"typescript": "^4.6.2"
},
"eslintConfig": {
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"env": {
"node": true
}
},
app.js
where I call Chalk:
import express, { json, urlencoded } from 'express';
import helmet, { contentSecurityPolicy } from 'helmet';
import morgan from 'morgan';
import Debug from 'debug';
import chalk from 'chalk';
console.log(`${chalk.red('Hello!'});
I could use some guidance as to why it’s throwing this for Chalk. I am not getting that error for my other Packages. Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
[eslint-config-airbnb] Unexpected top-level property ... - GitHub
Hi, I've been trying to install version 15.0.1, but I'm encountering the following error: ESLint configuration is invalid: - Unexpected ...
Read more >eslint-config-airbnb-base - npm
Airbnb's base JS ESLint config, following our styleguide. Latest version: 15.0.0, last published: a year ago.
Read more >13. Install and add ESLint Airbnb base config from ... - YouTube
In this video, we will see how to install and add the ESLInt config Airbnb base from NPM and extend the Airbnb in...
Read more >E24: Improve code quality using ESLint in IntelliJ
One of the most important steps you can take to improve the quality of your code is to use a quality assurance tool...
Read more >Credits - Enduvo
No. MODULE NAME/ COMPONENT PAGE LICENSE
1 Activity Indicator Progress Circle Homepage Show License
2 Assimp (see TriLib) Homepage Show License
3 async Homepage Show License...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Qix- it looks like the issue is because
"main": "./source/index.js",
is missing frompackage.json
.Once
main
is added topackage.json
linting passes.The linting error pops up due to package import-js/eslint-plugin-import. There is an open issue Rule import/no-unresolved raise false positive when there is no main field in the package.json #2132 but the maintainer of that package is adamant that proper etiquette is to include both
main
andexports
inpackage.json
. Main entry point export has also been referenced as justification for this requirement from the NodeJS website.Is this something you would be willing to add or would you prefer me to submit a PR with a fix? (I am new to this)
https://github.com/chalk/chalk/releases/tag/v5.0.1