How to run "stylelint --fix" with husky and lint-staged without blocking the commit - githooks

I'm using husky and lint-staged to run "stylelint --fix" on my sass files with this configuration
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git update-index --again"
}
},
"lint-staged": {
"resources/sass/*.scss": [
"stylelint --fix",
"git add"
]
}
and PhpStorm blocks my commit telling me this:
Commit failed with error, 0 file committed, 4 files failed to commit: test lintstaged husky > pre-commit (node v12.18.4) ⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index. [STARTED] Preparing... [SUCCESS] Preparing... [STARTED] Running tasks... [STARTED] Running tasks for resources/sass/*.scss [STARTED] stylelint --fix [FAILED] stylelint --fix [FAILED] [FAILED] stylelint --fix [FAILED] [SUCCESS] Running tasks... [STARTED] Applying modifications... [SKIPPED] Skipped because of errors from tasks. [STARTED] Reverting to original state because of errors... [SUCCESS] Reverting to original state because of errors... [STARTED] Cleaning up... [SUCCESS] Cleaning up... ✖ stylelint --fix: resources/sass/_custom.scss 614:1 ✖ Unexpected duplicate selector "body", first used at line 116 no-duplicate-selectors 974:11 ✖ Unexpected unknown type selector "readonly" selector-type-no-unknown 988:1 ✖ Unexpected duplicate selector "body", first used at line 116 no-duplicate-selectors 1313:1 ✖ Unexpected duplicate selector ".btn.clear", first used at line 418 no-duplicate-selectors husky > pre-commit hook failed (add --no-verify to bypass)
I read on the documentation that using the command "--no-verify" it skips "stylelint --fix", but I'd like to run "stylelint --fix" to fix the errors stylelint can fix and to skip the prevent commit.
In other words, I'd like to fix the errors that can be fixed automatically and to commit even if there are some warnings from stylelint.
Is it possible to do that?

Related

Git commit error occurs when executing create react-app command

I installed yarn, node, and git to the latest version and ran the yarn create react-app command within the path where the directory to create the project resides. However, near the end of the installation, a git commit error occurred.
I searched for the error and took action by referring to similar information, but the same error occurred.
The name and email were registered as global using the git config command.
yarn, node, git version:
yarn: 3.3.1
node: 18.12.0
git: 2.38.1
The following is a description of the error:
Git commit not created Error: Command failed: git add -A
at checkExecSyncError (node:child_process:871:11)
at execSync (node:child_process:943:15)
at tryGitCommit (D:\reactproject\start\.yarn\__virtual__\react-scripts-virtual-ffe325fc0b\0\cache\react-scripts-npm-5.0.1-d06bd2d5ad-92afa2f245.zip\node_modules\react-scripts\scripts\init.js:61:5)
at module.exports (D:\reactproject\start\.yarn\__virtual__\react-scripts-virtual-ffe325fc0b\0\cache\react-scripts-npm-5.0.1-d06bd2d5ad-92afa2f245.zip\node_modules\react-scripts\scripts\init.js:350:25)
at [eval]:3:14
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:313:38)
at node:internal/process/execution:79:19
at [eval]-wrapper:6:22 {
status: 128,
signal: null,
output: [ null, null, null ],
pid: 15184,
stdout: null,
stderr: null
}
Removing .git directory...
Success! Created start at D:\reactproject\start
Inside that directory, you can run several commands:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd start
yarn start
Happy hacking!

React native app failed to build while trying to bundle release

I created an app which worked perfectly on debug but when i run
./gradlew assembleRelease
the build failed to complete.
Below is the error I receive.
at ModuleResolver.resolveDependency (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:136:15)
at DependencyGraph.resolveDependency (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
at Object.resolve (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\lib\transformHelpers.js:129:24)
at resolve (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33)
at C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33)
at processModule (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
info Run CLI with --verbose flag for more details.
?[0K
?[0K
?[0K
?[3A?[1m<?[0;32;1m=?[0;39;1m------------> 13% EXECUTING [2m 37s]?[m?[38D?[1B?[1m> :app:bundleReleaseJsAndAssets?[m?[31D?[1B> IDLE?[6D?[1B?[3A?[0K
?[31;1m> Task :app:bundleReleaseJsAndAssets?[0;39m?[31m FAILED?[39m
?[1B?[0K
?[0K
?[3A?[1m<?[0;31;1m=?[0;39;1m------------> 13% EXECUTING [2m 37s]?[m?[38D?[1B> IDLE?[6D?[1B> IDLE?[6D?[1B?[3A?[0K
?[31mFAILURE: ?[39m?[31mBuild failed with an exception.?[39m
?[0K
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
?[33m> ?[39mProcess 'command 'cmd'' finished with non-zero exit value 1
* Try:
?[33m> ?[39mRun with ?[1m--stacktrace?[m option to get the stack trace.
?[33m> ?[39mRun with ?[1m--info?[m or ?[1m--debug?[m option to get more log output.
?[33m> ?[39mRun with ?[1m--scan?[m to get full insights.
* Get more help at ?[1mhttps://help.gradle.org?[m
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
?[31;1mBUILD FAILED?[0;39m in 2m 41s
24 actionable tasks: 2 executed, 22 up-to-date
?[0K
?[0K
?[0K
?[3A?[1m<?[0;1m-------------> 0% WAITING?[m?[26D?[1B> IDLE?[6D?[1B> IDLE?[6D?[1B?[3A?[2K?[1B?[2K?[1B?[2K?[2A
The graddle drama has been there since I first installed the react native framework, and all solution to get it fixed has yielded nothing. However, like I said early, I'm able to get the app run on emulators; even on physical device, the debug apk worked perfectly.
Help is appreciated
try this,
Close metro server if is opend
watchman shutdown-server
for delete node-modules and re install and clear-cache
watchman watch-del-all && rm -rf node_modules && npm cache clean --force && yarn install && npm start -- --reset-cache
3.after complete close the metro server, then next run this code
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
finally npx react-native run-android or yarn android
Did you try to re-bundle the entry file ?
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Here's an issue that seems related to yours: React-Native assembleRelease fails for task ':app:bundleReleaseJsAndAssets'

How to run Eslint only on changed files when a pull request is raised, in bitbucket pipelines?

We are building a bitbucket pipeline for a React Project. We have pre-commit hooks setup which does linting only on staged files.
How can I achieve the same in bitbucket pipelines, when a pull request is raised it get the diff files, and check the linting for those files only.
As described in this thread, as long as you are using a Docker node image, in which you can install and run ESLint, you should be able to add it to your BitBucket pipeline.
Make sure your pipeline is set to run only on PR:
pipelines:
pull-requests:
'**': #this runs as default for any branch not elsewhere defined
- step:
Example: bitbucket-pipelines.yml (to be tweaked to your specific project)
pipelines:
pull-requests:
'**':
- step:
name: Eslint for pull-request
image: node:12.14
condition:
changesets:
includePaths:
- resources/assets/js/**
script:
- printenv
- CAN_RUN_PIPELINE=$(test -f code_review/eslint/index.js && echo true || echo false)
- if [ "$CAN_RUN_PIPELINE" != true ]; then exit; fi
- git checkout origin/$BITBUCKET_PR_DESTINATION_BRANCH
- git merge origin/$BITBUCKET_BRANCH --no-edit
- git reset $BITBUCKET_PR_DESTINATION_COMMIT
- git add .
- git status
- npm i -g eslint
- npm install --only=dev
- npm install axios dotenv --save-dev
- eslint --format json -c code_review/eslint/rules.js -o ./code_review/eslint/output/output.json --ext .js,.jsx,.vue ./resources || true
- node ./code_review/eslint/index.js $REVIEW_AUTH_STRING

How to solve Command "yarn run build" exited with 1 Error!?

I've created my vercel app before, but when I tried to update with vercel --prod, I got
Error! Command "yarn run build" exited with 1
Error! Check your logs...
When I check my logs I got it, but I do not understand what to do with them because I had others empty vars, for example, but it was not a problem.
16:02:07.366 Retrieving list of deployment files...
16:02:08.837 Downloading 25 deployment files...
16:02:09.301 Analyzing source code...
16:02:10.840 Installing build runtime...
16:02:13.806 Build runtime installed: 2.965s
16:02:17.056 Looking up build cache...
16:02:19.686 Build cache downloaded [24.72 MB]: 2226.563ms
16:02:20.981 Detected package.json
16:02:20.982 Installing dependencies...
16:02:21.305 yarn install v1.22.17
16:02:21.420 [1/4] Resolving packages...
16:02:22.236 success Already up-to-date.
16:02:22.241 Done in 0.94s.
16:02:22.515 Running "yarn run build"
16:02:22.752 yarn run v1.22.17
16:02:22.793 $ react-scripts build
16:02:24.503 Creating an optimized production build...
16:02:25.419 Browserslist: caniuse-lite is outdated. Please run:
16:02:25.419 npx browserslist#latest --update-db
16:02:25.420
16:02:25.420 Why you should do it regularly:
16:02:25.420 https://github.com/browserslist/browserslist#browsers-data-updating
16:02:29.686
16:02:29.686 Treating warnings as errors because process.env.CI = true.
16:02:29.687 Most CI servers set it automatically.
16:02:29.687
16:02:29.687 Failed to compile.
16:02:29.687
16:02:29.688 src/App.js
16:02:29.688 Line 7:20: 'setProducts' is assigned a value but never used no-unused-vars
16:02:29.688
16:02:29.688 src/components/CartProduct/index.jsx
16:02:29.688 Line 7:17: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
16:02:29.688
16:02:29.689 src/components/Product/index.jsx
16:02:29.691 Line 7:13: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
16:02:29.691
16:02:29.691
16:02:29.714 error Command failed with exit code 1.
16:02:29.714 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
16:02:29.732 Error: Command "yarn run build" exited with 1
In your eslint config file, turn off no-unused-var
"rules": {
.....
"no-unused-vars": "off"
.....
}
and add Alt for your images tags with or without text:
<img src="[image url]" alt="" />

How do I deploy an updates project and publish on github?

The issues I am having the past few days is that I can not update my 
https://filipzafran.github.io/Best-TO-DO-App-in-the-history-of-the-universe/  website page.
Although the gh-pages branch is updated with the new code, it still shows the old one.
I have:
 - deleted and created again the gh-pages
 - pushed a new commit 
 - re-merged with master
 - cleared browser history (catche)
 - read numerous solutions
Still cant make it publish the new code on my gh-pages website.
I feel like there might have to do with depolyment.
Do I need to deploy again?
Because when I do, from master, it gives me a long error:
redux-todo-step_by_step git:(master) npm deploy
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/home/ficho/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#6.14.7 /home/ficho/.nvm/versions/node/v13.8.0/lib/node_modules/npm
Did you mean this?
repo
This is my repo.
Assuming you have a deploy script in your package.json, to successfully execute it you have to type in npm run deploy as deploy isn't an npm command per se.
In npm, run is the command that allows you to execute your custom scripts.
Here's an example of a package.json and relative commands...
{
"name": "raci-api",
"version": "0.4.0",
"description": "raci API",
"main": "src/server.js",
"scripts": {
"start:dev": "nodemon src/server.js -e \"NODE_END=development\"",
"start:production": "node src/server.js -e \"NODE_ENV=production\"",
"lint": "eslint src/**/*.js",
"lint:fix": "eslint --fix src/**/*.js",
"docs:serve": "npx http-server -c-1 docs -o",
},
"author": "",
"license": "ISC",
"repository": {
"type": "git",
"url": "yourRepoURL"
},
"dependencies": {
"yourDependencies": "here"
},
"devDependencies": {
"yourDevDependencies": "here"
}
}
In this case, to properly serve the app (E.G. in loopback) you have to use npm run start:dev.

Resources