-
Notifications
You must be signed in to change notification settings - Fork 0
Initial implementation of shared eslint config #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * @bajtos @juliangruber @pyropy @NikolasHaimerl | ||
| package.json | ||
| package-lock.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: 'npm' | ||
| directory: '/' | ||
| schedule: | ||
| interval: 'daily' | ||
| time: '09:00' | ||
| timezone: 'Europe/Berlin' | ||
| commit-message: | ||
| prefix: 'deps' | ||
| prefix-development: 'deps(dev)' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| - run: npm ci | ||
| - run: npm run lint |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Dependabot auto-approve minor updates | ||
| on: pull_request | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| dependabot: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.actor == 'dependabot[bot]' }} | ||
| strategy: | ||
| matrix: | ||
| dependencyStartsWith: | ||
| - prettier | ||
| - neostandard | ||
| - eslint | ||
| steps: | ||
| - name: Dependabot metadata | ||
| id: metadata | ||
| uses: dependabot/fetch-metadata@v2 | ||
| with: | ||
| github-token: '${{ secrets.GITHUB_TOKEN }}' | ||
| - name: Approve a PR | ||
| if: ${{startsWith(steps.metadata.outputs.dependency-names, matrix.dependencyStartsWith) && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')}} | ||
| run: gh pr review --approve "$PR_URL" | ||
| env: | ||
| PR_URL: ${{github.event.pull_request.html_url}} | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Dependabot auto-merge | ||
| on: pull_request | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| dependabot: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.actor == 'dependabot[bot]' }} | ||
| steps: | ||
| - name: Enable auto-merge for Dependabot PRs | ||
| run: gh pr merge --auto --squash "$PR_URL" | ||
| env: | ||
| PR_URL: ${{github.event.pull_request.html_url}} | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * @typedef {import('prettier').Config} Config | ||
| * @see https://prettier.io/docs/configuration | ||
| */ | ||
|
|
||
| /** @type {Config} */ | ||
| export default { | ||
| plugins: [ | ||
| // Order of plugins is important! | ||
| // See https://github.com/electrovir/prettier-plugin-multiline-arrays?tab=readme-ov-file#compatibility | ||
| 'prettier-plugin-packagejson', | ||
| 'prettier-plugin-jsdoc', | ||
| ], | ||
|
|
||
| // built-in options | ||
| semi: false, | ||
| singleQuote: true, | ||
|
|
||
| // prettier-plugin-jsdoc | ||
| tsdoc: true, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,11 @@ | ||
| # eslint-config | ||
|
|
||
| Shared configuration for ESLint based on Neostandard | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing docs for how to use this config, could you add that too? |
||
|
|
||
| ## Development | ||
|
|
||
| Publish a new version: | ||
|
|
||
| ```bash | ||
| $ npx np | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import neostandard from 'neostandard' | ||
|
|
||
| export default neostandard({ | ||
| noStyle: true, // Disable style-related rules, we use Prettier | ||
| ts: true, | ||
| }) | ||
|
Comment on lines
+3
to
+6
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not convinced that sharing a two-line configuration is worth the extra ceremony required. (This patch has +4,949 new lines.) We will also need to remember to periodically publish new versions of this package in order to ship neostandard updates to our repositories. @juliangruber WDYT?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see it this way, the PR is already there and the extra code is basic orchestration. There are many repositories where the extra code is so much more than the actual code. We might also develop the eslint config in the future, or perform tooling upgrades. We don't want to do this in every repo one by one.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do wonder though if there's a better way to share this config
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For one, can we share the eslint and prettier config from one repo? This way there's half the orchestration, and less updates. It gets closer to my desire of having just one package for all things listing & formatting.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about this quite a bit. Neostandard is already the shared linter config that shields us from the details of eslint configuration. The two tweaks we need to make - enable The situation with Prettier is more complex; we need our custom shared config. Prettier provides a neat solution for that: {
"prettier": "@CheckerNetwork/prettier-config"
"devDependencies": {
"@CheckerNetwork/prettier-config": "^1.0.0",
"prettier": "^3.5.3"
}
}Is it worth innovating here? I am happy to follow the default Prettier approach.
It's not the typical path supported by Prettier. I see two potential options we can explore:
I am not convinced the benefit of having one repo combining eslint and Prettier config is worth deviating from the typical path, though. These two configurations are independent (as long as we keep eslint style-rules disabled).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, if that's not supported, let's not innovate. +1 to inlining the neostandard config, and using one repo for the prettier config
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to go the overall simplest path possible here |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alleviating your concerns about PR size a bit, this file can be removed as we make this repo also depend on the shared prettier config