Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial setup #1

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root=true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{mjs,cjs,js,mts,cts,ts,json,vue,html,scss,css,toml,md}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
40 changes: 40 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup
description: Configure Node.js + pnpm and install dependencies

inputs:
registry:
description: NPM registry to set up for auth
required: false

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
registry-url: ${{ inputs.registry }}

- uses: pnpm/action-setup@v4
name: Setup pnpm
id: pnpm-install
with:
run_install: false

- name: Get pnpm cache dir
id: pnpm-cache-dir
shell: bash
run: echo "pnpm-cache-dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache-dir.outputs.pnpm-cache-dir }}
key:
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run linter
run: pnpm run lint

typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run typecheck
run: pnpm run typecheck
108 changes: 108 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: SemVer for the release, for example "1.0.0"
required: true
type: string

permissions:
contents: write

jobs:
check-version:
name: Check Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.release }}
is-prerelease: ${{ steps.version.outputs.prerelease && true || false }}
steps:
- name: Check version
uses: madhead/semver-utils@v4
id: version
with:
version: ${{ inputs.version }}
lenient: false

create-version:
name: Create Version
runs-on: ubuntu-latest
needs: check-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Bump version
run: pnpm version --no-git-tag-version '${{ needs.check-version.outputs.version }}'

- name: Create version commit & tag
run: |
author='${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>'
version='v${{ needs.check-version.outputs.version }}'
branch='${{ github.ref }}'
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit --all --author "$author" --message "$version"
git tag --annotate "$version" --message "$version"
git push --atomic origin "$branch" "$version"
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- check-version
- create-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
'v${{ needs.check-version.outputs.version }}' \
--verify-tag \
--generate-notes \
${{ needs.check-version.outputs.is-prerelease == 'true' && '--prerelease' || '' }}
publish-npm:
name: Publish to NPM
runs-on: ubuntu-latest
needs:
- check-version
- create-version
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: refs/tags/v${{ needs.check-version.outputs.version }}

- name: Setup env
uses: ./.github/actions/setup
with:
registry: https://registry.npmjs.org

- name: Build
run: pnpm run build

- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
pnpm publish \
--access=public \
--no-git-checks \
--tag ${{ needs.check-version.outputs.is-prerelease == 'true' && 'canary' || 'latest' }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# User preferences
.DS_Store

# Dependencies
node_modules/

# Builds / Caches
dist/
coverage/
*.tsbuildinfo
.eslintcache

# IDEs / Editors
.idea/
*.code-workspace
.history/
*.sublime-settings
.*.swp
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
engine-strict=true
shell-emulator=true
save-prefix=''
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "editorconfig.editorconfig"]
}
55 changes: 55 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"json5",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
],

// Enable experimental support for TS config file
"eslint.options": {
"flags": ["unstable_ts_config"]
}
}
3 changes: 3 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import directusConfig from './src/index.js';

export default directusConfig();
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Directus
paescuj marked this conversation as resolved.
Show resolved Hide resolved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@directus/eslint-config",
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "Shared ESLint config used in Directus projects",
"author": {
"name": "Monospace Inc",
"email": "[email protected]",
"url": "https://monospace.io"
},
"license": "MIT",
"funding": "https://github.com/directus/directus?sponsor=1",
"homepage": "https://directus.io",
"repository": {
"type": "git",
"url": "git+https://github.com/directus/eslint-config.git"
},
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"engines": {
"node": "18 || 20",
"pnpm": "9"
},
"maintainers": [
{
"name": "Pascal Jufer",
"email": "[email protected]",
"url": "https://github.com/paescuj"
}
],
"scripts": {
"build": "pnpm run '/^(bundle|typecheck)$/'",
"bundle": "tsup src/index.ts --format=esm --dts --minify",
"typecheck": "tsc --noEmit",
"lint": "eslint --flag unstable_ts_config .",
paescuj marked this conversation as resolved.
Show resolved Hide resolved
"inspect": "pnpm dlx @eslint/config-inspector --config eslint.config.ts"
},
"peerDependencies": {
"eslint": "^9.10"
},
"dependencies": {
"@antfu/eslint-config": "3.11.2",
"eslint-flat-config-utils": "0.4.0",
"eslint-plugin-format": "0.1.3",
"prettier": "3.4.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason prettier is in here?

},
"devDependencies": {
"@directus/tsconfig": "2.0.0",
"eslint": "9.16.0",
paescuj marked this conversation as resolved.
Show resolved Hide resolved
"jiti": "2.4.1",
"tsup": "8.3.5",
"typescript": "5.7.2"
}
}
Loading