Given a project with its node's package.json installing eslint and a few plugins, how can I know where a particular rule is set?
I see a rule being applied (space-before-function-paren) but I cannot find it either in any of the .eslintrc files in the project, or in the documentation of the plugins.
Additionally, I'm working with VSCode with some extensions such as ESLint itself, which could potentially be interfering here, but again I'm not sure how/where to check which part is applying that rule (though I think this is unlikely to be happening, as npm run lint fails if the code fails against the mentioned rule.
I'm posting the relevant parts of the package.json file:
{
// ...
"scripts": {
"watch": "NODE_ENV=development node build/build.js --watch",
"build": "NODE_ENV=development node build/build.js",
"build:prod": "NODE_ENV=production node build/build.js",
"unit": "NODE_ENV=test jest --config test/unit/jest.conf.js --coverage",
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit/specs",
"ci-lint": "eslint --ext .js,.vue src test/unit/specs --format checkstyle --output-file lint_out/unit_timeline.xml"
},
"devDependencies": {
"#vue/test-utils": "^1.0.0-beta.27",
"autoprefixer": "^8.2.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.4",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"chalk": "^2.3.2",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"cssnano": "^3.10.0",
"eslint": "^5.10.0",
"eslint-config-standard": "^12.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.11",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^3.1.0",
"jest": "^22.4.3",
"jest-junit": "^3.6.0",
"jest-serializer-vue": "^1.0.0",
"node-notifier": "^5.2.1",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^2.0.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.3",
"postcss-url": "^7.3.1",
"rimraf": "^2.6.2",
"sass-loader": "^6.0.7",
"semver": "^5.5.0",
"shelljs": "^0.8.1",
"uglifyjs-webpack-plugin": "^1.2.4",
"url-loader": "^1.0.1",
"vue-jest": "^2.3.0",
"vue-loader": "^14.2.2",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.21",
"webpack": "^3.11.0",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-file-list-plugin": "0.0.6",
"webpack-merge": "^4.1.2",
"yargs": "^11.0.0"
}
// ...
}
Unfortunately, it seems there's no "eslint" way to perform such a report.
If you run eslint with debug options, you get a lot of information about how the program runs: what file is processing, with which configuration, how it fails, etc., but not from where a rule was taken.
I managed to find it by simply running a grep + find within the node_modules directory, and being sure which module was providing the rule by simply changing it and seeing the eslint results afterwards.
Related
I am working on a NestJS project. I am trying to start project but I am getting error: dotenv: command not found in the terminal. I have checked the packages.json and I can see to dotenv installed. Moreover I have tried to install dotenv with Yarn but still I am getting same error.
Dependencies in package.json:
"dependencies": {
"#nestjs/common": "^8.1.1",
"#nestjs/config": "1.0.2",
"#nestjs/core": "^8.1.1",
"#nestjs/jwt": "^8.0.0",
"#nestjs/passport": "^8.0.1",
"#nestjs/platform-express": "^8.1.1",
"#nestjs/swagger": "^5.1.2",
"#prisma/client": "3.3.0",
"bcrypt": "^5.0.1",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
-> "dotenv": "^10.0.0",
"express-rate-limit": "^5.5.0",
"helmet": "^4.6.0",
"nanoid": "^3.1.30",
"nodemailer": "^6.7.0",
"passport": "^0.5.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.12",
"request-ip": "^2.1.3",
"rimraf": "^3.0.2",
"rxjs": "^7.4.0",
"swagger-ui-express": "^4.1.4"
},
The starting script that I am using:
"start:dev": "dotenv -e env/local.env -- nest start --watch",
I found the solution and it may help someone else. To run dotenv command in terminal we need dotenv-cli. Installing dotenv-cli with yarn add dotenv-cli solved my problem.
I have a jquery/react web application that only fails when I try to access the heroku production deployment on IE 11. When built locally, the app runs fine on IE 11. All other browsers function as expected in both local and production environment.
The error I'm getting is 'SCRIPT1010: Expected identifier'. It points to this line in my main.js, {var n=e&&e.__esModule?function(){return e.default}:function(){return e};
I've attempted to add various polyfills to no effect. The fact that this fails only in the production version and specifically on IE 11 confuses me. If you any insight or can even assist with some tips as to how to better debug in IE, it would be greatly appreciated as I'm accustomed to using just chrome developer tools.
Thanks.
Edit: here is the dependency portion of my package.json:
"dependencies": {
"12factor-config": "^1.3.1",
"axios": "^0.17.1",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"body-parser": "^1.18.2",
"consolidate": "^0.14.5",
"express": "^4.15.3",
"gsap": "^1.20.4",
"handlebars": "^4.0.10",
"hoek": "^5.0.3",
"jquery": "^3.3.1",
"jquery-ui": "^1.12.1",
"lodash": "^4.17.5",
"marked": "^0.3.17",
"newrelic": "^4.2.0",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-hot-loader": "^3.1.3",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"webpack": "^3.10.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^2.11.0"
},
I narrowed the problem down to the 'gsap' dependency, for some reason this was breaking production on IE11.
I am upgrading from angular 2 to angular 5.
after upgradation I am seeing the below errors in the the ts file.
in angular5 do I need to remove #angular/core and #angular/router
after upgradation providing the package.json also
providing my error and code snippet below.
can you tell me how to fix it.
error
[ts] Cannot find module '#angular/core'.
[ts] Cannot find module '#angular/router'.
code
import {Component, ElementRef, Input,Output,EventEmitter,Inject, OnInit,ViewChild} from '#angular/core';
import {KendoGridComponent} from '../grid/grid.component'
import { Router} from '#angular/router';
package.json
{
"name": "SPORTS",
"version": "1.0.0",
"description": "SPORTS player - v0.2.37.1",
"engines": {
"node": "7.10.1"
},
"license": "ISC",
"dependencies": {
"#angular/animations": "^5.2.2",
"#angular/common": "^5.2.2",
"#angular/compiler": "^5.2.2",
"#angular/compiler-cli": "^5.2.2",
"#angular/core": "^5.2.2",
"#angular/forms": "^5.2.2",
"#angular/http": "^5.2.2",
"#angular/platform-browser": "^5.2.2",
"#angular/platform-browser-dynamic": "^5.2.2",
"#angular/platform-server": "^5.2.2",
"#angular/router": "^5.2.2",
"#angular/upgrade": "2.0.0",
"#ng-idle/core": "2.0.0-beta.2",
"#ng-idle/keepalive": "2.0.0-beta.2",
"#types/jquery": "^3.2.10",
"#types/node": "^8.0.18",
"#types/underscore": "^1.8.1",
"#types/webpack": "^3.0.5",
"angular2-in-memory-web-api": "0.0.21",
"angular2-router-loader": "^0.3.5",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^3.2.1",
"babel-minify-webpack-plugin": "0.2.0",
"bootstrap": "^3.3.6",
"commander": "^2.6.0",
"compression-webpack-plugin": "1.0.1",
"core-js": "^2.4.1",
"css-loader": "^0.28.7",
"del": "^3.0.0",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"file-saver": "^1.3.3",
"html-webpack-plugin": "^2.30.1",
"http-post": "^0.1.1",
"http-proxy": "^1.8.1",
"jquery": "2.2.3",
"pako": "^1.0.5",
"path": "^0.12.7",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.3",
"require": "^2.4.20",
"rxjs": "^5.5.6",
"style-loader": "^0.18.2",
"text-encoding-shim": "^1.0.0",
"to-string-loader": "^1.1.5",
"ts": "0.0.0",
"typescript": "^2.4.2",
"uglifyjs-webpack-plugin": "^0.4.6",
"underscore": "^1.8.3",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0",
"zone.js": "^0.6.23"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean-css": "^3.8.0",
"gulp-concat": "^2.6.1",
"gulp-util": "^3.0.8",
"jasmine-core": "~2.4.1",
"jasmine-expect": "^3.0.1",
"jasmine-jquery": "^2.1.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^0.2.3",
"karma-cli": "^0.1.2",
"karma-coverage": "^1.1.1",
"karma-htmlfile-reporter": "^0.2.2",
"karma-jasmine": "^0.3.8",
"karma-jquery": "^0.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^2.1.4",
"karma-typescript-preprocessor": "^0.3.0"
},
"main": "server.js",
"scripts": {
"dev": "webpack-dev-server --config ./webpack.dev.js --inline --progress --color ",
"postinstall": "webpack -p --config ./webpack.prod.js --progress --profile --bail",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "https://github.iSPORTS.com/player-Replatform/webcomponent.git"
}
}
You need to install these dependencies manually.
$ npm i #angular/core -s
$ npm i #angular/router -s
I also faced the same issue while upgrading because of npm. I suggest you start using yarn instead.
Is this error coming from the compiler or an IDE tool like Intellisense? I find sometimes with installing/branch switching IDE tools like this can get confused and require a restart of the IDE.
If it won't compile, are the modules actually in your node_modules? If not, delete your package-lock.json or shrinkwrap.json and install again. NPM adds the package lock by default as of 5.0 and I find with complicated dependencies it can mess up sometimes.
If they are there, run npm prune and npm install again.
If that doesn't work, nuke node_modules alongside any lock file and install again.
Do any third-party libraries require an update? Angular 5 had some breaking API changes. Check their docs if that's the case.
Consider Yarn.
I'm pretty sure it's the first one, but I'll leave all the steps I usually take just for the sake of completion.
Make sure you are exporting RouterModule in each router module that has children. In the angular documentation this is not explicitly stated as being necessary -- it's merely included in the examples -- but it is necessary, as one finds out after the customary several hours of edit-run-sigh, edit-run-shout, edit-run-google-editWithHope-scream-considerSmashingKeyboard, edit-run-cry, edit-run-solveByAccident-feelMomentaryPride (repeat).
The upshot: include RouterModule. The meta upshot: pay attention to the little seemingly unnecessary code in official documentation.
Changed react and react-dom to 16.2.0 in my package JSON and receiving the following error.
Uncaught Error: Cannot find module "react/lib/ReactComponentTreeHook"
Have tried clearing my node_modules, reinstalling everything, starting with a fresh project and adding dependencies in small chunks to narrow down the issue, and trying just about every option already seen on stack overflow.
my package.json is as follows:
{
"name": "",
"version": "0.0.1",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "..."
},
"scripts": {
"dev": "webpack -d --watch",
"build": "webpack -p"
},
"dependencies": {
"axios": "^0.17.1",
"body-parser": "^1.18.2",
"classnames": "^2.2.5",
"connect-mongo": "^2.0.0",
"cookie-parser": "^1.4.3",
"express": "^4.16.2",
"express-session": "^1.15.6",
"moment": "^2.19.3",
"mongoose": "^4.13.6",
"multer": "^1.3.0",
"node-sass": "^4.7.2",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"qs": "^6.5.1",
"react": "^16.2.0",
"react-click-outside": "^3.0.0",
"react-dom": "16.2.0",
"react-redux": "5.0.6",
"redux": "3.7.2",
"redux-logger": "^3.0.6",
"redux-promise-middleware": "^5.0.0",
"redux-thunk": "^2.2.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"redux-devtools": "^3.4.1",
"sass-loader": "^6.0.6",
"serve": "^6.4.1",
"style-loader": "^0.19.0",
"svg-sprite-webpack-plugin": "^1.1.0",
"svg-spritemap-webpack-plugin": "^1.0.3",
"url-loader": "^0.6.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^3.10.0"
},
"author": "",
"license": "ISC",
"homepage": ""
}
After placing a breakpoint at the line erroring out, it seems that the stack trace is coming form the import of react-dom, but if that is at the latest version matching react, i don't understand why i am having this issue.
Out of options that I can think of, would appreciate any help. Thanks.
Have tried clearing my node_modules, reinstalling everything
Remember that since NPM 5-th version it generates package lock file, without purging that reinstalling modules will not work appropriately.
Also check following - if some package has own dependency on old react package version, it will be installed into nested node_modules directory, and then everything is dependent on project/loaders structure. In come circumstance, invalid new or old package version will be loaded. In some npm packages, like graphql, special warning added for that case: "Maybe you have installed different version of package".
So, check other packages' versions, and maybe update them.
I am having this issue while installing all node_modules. And this is making me crazy.
babel-loader#7.1.2 requires a peer of webpack#2 || 3 but none was
installed.
Here is my package.json file
{
"name": "react-router-firebase-auth",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react-scripts": "0.9.5"
},
"dependencies": {
"#atlaskit/button": "3.0.0",
"#atlaskit/css-reset": "1.1.4",
"#atlaskit/field-text": "4.0.1",
"#atlaskit/modal-dialog": "2.1.1",
"#atlaskit/page": "4.0.1",
"#atlaskit/util-shared-styles": "2.3.1",
"#shopify/polaris": "^1.5.1",
"babel-eslint": "^7.0.0",
"bootstrap": "^3.3.7",
"eslint": "3.16.1",
"eslint-plugin-react": "6.4.1",
"express": "^4.16.1",
"firebase": "^4.5.0",
"firebase-admin": "^5.4.1",
"firestore": "^1.1.6",
"fixed-data-table": "^0.6.4",
"griddle-react": "^1.8.1",
"jquery": "^3.2.1",
"node-localstorage": "^1.3.0",
"nodemon": "^1.12.1",
"react": "^15.5.3",
"react-bootstrap": "^0.31.3",
"react-bootstrap-button-loader": "^1.0.8",
"react-bootstrap-navbar": "^1.1.0",
"react-data-grid": "^2.0.59",
"react-date-picker": "^6.1.2",
"react-dom": "^15.5.3",
"react-fontawesome": "^1.6.1",
"react-router-dom": "^4.0.0-beta.8",
"react-scripts": "^0.9.5",
"react-transition-group": "^1.2.0",
"reactstrap": "^4.8.0",
"requestify": "^0.2.5",
"simple-react-bootstrap": "^0.2.7",
"styled-components": "1.4.6",
"url": "^0.11.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I am using create-react-app for this project. So i could not change webpack.config.js file. What am i supposed to do here?
Please read this post. It describes what a peer dependency is.
https://stackoverflow.com/a/34645112/2379376
What that means is that you have webpack not installed at all or you have a different version (webpack 1.x) installed. But this plugin needs webpack in version 2 or 3 to function properly.
What you can do is
npm install webpack -g
So npm will install the newest version of webpack on your system.
But now other peer warnings could occur when other loaders need an older version of webpack.
When using Webpack 4:
I've faced the same error but I actually had the webpack 4 installed. In order to solve this I used the instruction on babel-loader documentation and installed the following extra libraries: babel-loader, #babel/core and #babel/preset-env.
Command to install all the required libraries:
npm install -D babel-loader #babel/core #babel/preset-env webpack
package.json devDependencies before the installation:
"devDependencies": {
"chai": "^4.1.2",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"expect": "^22.0.3",
"jest-junit": "^3.3.0",
"jest-junit-reporter": "^1.1.0",
"node-sass": "^4.9.2",
"prop-types": "^15.6.0",
"react-test-renderer": "^16.2.0",
"redux-mock-store": "^1.4.0",
"sass-loader": "^6.0.6",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
}
After the installation:
"devDependencies": {
"#babel/core": "^7.1.6",
"#babel/preset-env": "^7.1.6",
"babel-loader": "^8.0.4",
"chai": "^4.1.2",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"expect": "^22.0.3",
"jest-junit": "^3.3.0",
"jest-junit-reporter": "^1.1.0",
"node-sass": "^4.9.2",
"prop-types": "^15.6.0",
"react-test-renderer": "^16.2.0",
"redux-mock-store": "^1.4.0",
"sass-loader": "^6.0.6",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
}
Hope it helps
Install webpack globally in node environment as well as in development(as dev dependency).
As main function of webpack is to bundle JavaScript files for usage in a browser.As each time you made changes to index.js (entry point of npm) at development time then you have to run webpack to make changes in bundle.js file also, so we need to install in both the environment(ie. node environment and development environment)
Run below command to solve the issue:
npm install -g webpack#3.10.0
npm install --save-dev webpack#3.10.0
Here I am using 3.10.0 for webpack. You can use 4 as well. I think this will help.