Comments (14)
Sounds good to me! Happy to see a PR to see how the CSS will be updated. :)
from confs.tech.
I was reading about husky and I noticed that its being use in the repo as well.
from confs.tech.
I am sorry but the repo does not use tailwind at all. I just realized that it is using SCSS for all the styling. LOL
I still want to work on the solution to ensure a formatting rules regardless of whether developers manually format their code.
from confs.tech.
Haha that's true, I thought it was a catch-all kind of linter.
You can run npm lint --fix locally, otherwise I believe you can activate a settings on VSCode to auto format based on eslint
from confs.tech.
I found a better approach by running Prettier as a GitHub Action:
name: Check Code with Prettier
on:
pull_request:
branches:
- "main"
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Download dependencies
run: npm ci
- name: Run prettier
run: npm run format
What do you think @nimzco?
from confs.tech.
That will "pretty" the code on the CI action but won't add a new commit to the branch though.
Also, I don't know why, but when I ran this command locally, it wasn't formatting the file I had to format, so I'm a bit confused on the current config :/
from confs.tech.
That will "pretty" the code on the CI action but won't add a new commit to the branch though.
Update to "Format Code with Prettier"
name: Format Code with Prettier
on:
pull_request:
branches:
- "main"
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run Prettier
run: npm run prettier
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "changes_detected=false" >> $GITHUB_ENV
fi
- name: Commit and Push changes
if: env.changes_detected == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: fix formatting issues"
git push origin HEAD:${{ github.head_ref }}
- Ensure Workflow read and write permissions are enable
- Add script:
"scripts": {
"prettier": "npx prettier --write \"**/*.{ts,tsx,}\""
}
This approach will Commit and Push changes.
Is this better @nimzco? the workflow works for me in a personal repo
from confs.tech.
Code looks good, let's open a PR to test it!
Does it currently format all files? I ran prettier locally, and it formatted too many files vs what the nom run build
script expects.
from confs.tech.
It run into a Permissions error but it did format all .ts
and .tsx
files
from confs.tech.
Hmm. I've never tried to do this, but look at what github actions are available out there.
I see this after a quick googling: https://github.com/orgs/community/discussions/24945#discussioncomment-3245946
from confs.tech.
Or I see: https://github.com/marketplace/actions/add-commit
from confs.tech.
I will take a look at that tomorrow. Thanks.
I was wondering if we could use the confs.bot for this? Or give similar permissions.
In my project, I went into the repo setting 》actions 》enable read and write permissions.
from confs.tech.
You mean this:
The bot is a user I think, so you might need to use a different user to push? 🤔
from confs.tech.
Yes, it needs to have the contents: write permission enabled
for the GITHUB_TOKEN in the GitHub Actions workflow to be able to commit and push changes back to the repository
from confs.tech.
Related Issues (20)
- Blank screen after clicking on sections HOT 3
- Fix end date error when same date HOT 3
- Allow filtering by continents
- Feature Request: want to show all past conferences with recorded video sites? HOT 7
- Feature Request: Calendar View HOT 7
- Filter that shows only conferences that are in-person HOT 4
- Bug report, Top Level Domain is crashing. HOT 4
- Handle malformatted date. HOT 1
- Pull in Testing conferences HOT 4
- Add new topic: AWS HOT 1
- Adding a new conference from the form silently fails
- Add Full Stack as a topic HOT 1
- Conference Changes HOT 1
- Add another filter-tag #opensource for Open Source conferences
- Incorrect URL in readme file
- Readme Update
- Feature Request: Team Page to Showcase the Community HOT 3
- Integrate GitHub star HOT 3
- GitHub Actions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from confs.tech.