I am developing in a monorepo. In our team, we have two different eslint configurations... one for the frontend and another one for the backend.
Our project structure is:
/
app/
components/
SomeComponent/
XD.js
App.js
assets/
core/
functions/ <--- Backend
src/
node_modules/
.eslintignore
.eslintrc.js
package.json
node_modules/
.eslintignore
.eslintrc.js
Main.js
package.json
Our top level .eslintignore (not the one in the backend) looks like the following:
node_modules/
core/
functions/
With this, we are trying to ignore the files that are inside these directories when executing the linting script which is situated in our package.json (again, not the one inside the backend folder).
This is the script I have in my package.json
"lint": "eslint *.js ./app/**/*.js"
The problem I am expecting is that my editor detects the linting errors... but when running
yarn lint
I get
$ eslint .js ./app/**/.js ✨ Done in 5.27s.
It seems that the script is not linting all the files... why?
Note:
When changing the script to:
eslint . --ext .js,.jsx,.cjs,.mjs
it works.
Related
my current folder structure is
-- project folder
|-- package.json
|-- react-project
|-- src folder
|-- public folder
My node version is 18
In order for npm start to work, you have to run the command from the same directory as your package.json.
node_modules, package-lock.json, and package.json should always be at the root of the project as a good practice.
If you move these files/folders it can disrupt the pathing of them.
For example, inside package.json at the top you will a line somewhat like: "main": "node_modules/expo/AppEntry.js". If you move node_modules or package.json, then this will no longer work. It would need to be changed to something like, "./node_modules" or "../node_modules"
If there is a specific reason you need to move this folder, then you will have to do some reconfiguring to ensure the pathing is correct.
I'm trying to implement eslint in a Next.js project.The file structure look like below
.eslintignore
.eslintrc.js
.next
.prettierrc
.stylelintrc.js
components
forms
modals
modules
node_modules
And I have node_modules/* in my .eslintignore file. When I try to lint these by eslint --fix /sources/**/*.js I am getting below error
You are linting "/sources/node_modules/ally.js", but all of the files matching the glob pattern "/sources/node_modules/ally.js" are ignored.
Anyone can help me to solve this? Thanks
If .eslintignore located in the same directory as node_modules you can specify it as node_modules.
# .eslintignore
node_modules
**/.next/**
**/_next/**
**/dist/**
.eslintignore follows .gitignore syntax.
See .gitignore specs for more details.
Background
I have been using bower for handling dependencies, however now I would like to migrate to yarn. The main hurdle I am having is migrating from the below .bowerc file to .yarnrc.
.bowerrc
{
"directory": "src/vendors"
}
The issue is I could make a .yarnrc file, like below that will put any dependency into src/vendors, but that includes devDependencies.
.yarnrc
--modules-folder src/vendors
Question
How do I only put dependencies into src/vendors and putdevDependencies in node_modules?
An alternative way to accomplish the same thing as in the answer above (but without the .yarnrc files) is by adding two different scripts to package.json, something along these lines:
"scripts": {
"install-depends": "yarn install --production=true --modules-folder ./src/vendors",
"install-devDepends": "yarn install --production=false"
}
Then you just run them in that same order (if you do it the other way around, it will wipe out everything in the node_modules:
yarn run install-depends
yarn run install-devDepends
You could use --production option to tell yarn which dependencies you want to install; if set to true it will just install dependencies.
So in your src folder make a .yarnrc file with the following content:
--modules-folder vendors
--production true
and in your project dir, in .yarnrc file, set --production to false:
--production false
folder structure:
.
├── package.json
├── src
│ └── .yarnrc
└── .yarnrc
We have a typescript app that lives in /src. We have tests that live in /tests. Locally, when we run TSC, it compiles both and deposits them to /dist/src and /dist/test respectively.
We also have a Dockerconfig that tells docker to ignore a bunch of dev files including /tests. When Docker runs tsc, it only sees /src and so it deposits all of /src to /dist -- meaning that when we have -- for example -- a /services folder that gets compiled to /dist/src/services/whatever.js locally; we see it at /dist/services/whatever.js in our container.
Our dockerfiles are small, they just run TSC and set entrypoints. Do we need to be more explicit with our dockerfiles? Is this a problem that people have found elegant solutions for?
It's difficult to say without knowing exactly what directories are being mounted, and where in the docker container, but this sounds like a problem that should be solved with tsconfig.json, possibly with some creative use of the docker files if necessary.
For example, I have a dockerfile for tsc and it looks about like this:
FROM alpine:latest
RUN apk update && apk add nodejs && rm -rf /var/cache/apk/*
RUN npm install -g typescript#~1.6
RUN mkdir /tsc
WORKDIR /tsc
ENTRYPOINT ["tsc"]
This container will be executed like this:
docker run tsc -v "./:/tsc"
And if my directory tree looks like this:
.
├── tsconfig.json
├── dist
├── src
├── test
Then I see a few different possibilities for tsconfig.json:
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist/src"
}
}
OR
{
"exclude": ["test"]
}
I am currently working on my first AngularJS app and my directories are setup like this
app/
assets/
<css, js, images etc...>
bower_components/
<various bower things>
components/
<controllers, directives etc. in sub folder components>
partials/
app-controller.js
app.css
index-async.html
index.html
node_modules/
<various node things>
test/
<karma>
bower.json
package.json
I am extremely confused as to how bower/node packages fit into this equation. I started this project using the angular-seed git repo, and have since modified the structure to match google's best practices structure.
The Angular seed project references files in the html by using "bower_components/component", but than it has the bower_components folder ignored in the .gitignore file. If the bower_components and the node components folders are ignored, than wouldnt it be bad to reference these in your html if they are not supposed to go along with the final product?
This is because the command bower install will install all the dependencies for your project into that directory based on whats listed in your bower.json file.
There is no need to check in the dependencies in your git repo, just check in bower.json.
When installing new packages with bower the -s flag can be added to the command to persist the new package to the bower.json file. bower install -S <package>
Normally Grunt or Gulp has build task set up to run the bower install command for you when you build your project.
But do not reference libraries in the node_modules folder in your client side app, only on the server side.
But the same goes for node_modules the folder should be git ignored, but make sure to check in your packages.json file which is npm's (node package manager) bower.json equivelent.