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

Add basic ESLint config, lint script and lint CI job #1640

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
.github
.changeset
54 changes: 54 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module.exports = {
root: true,
extends: ['eslint:recommended'],
plugins: ['no-only-tests'],
env: {
browser: true,
node: true,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json', './docs/tsconfig.json'],
},
ignorePatterns: ['**/node_modules/*', '**/dist/*'],
rules: {
'no-only-tests/no-only-tests': 'warn',
'no-mixed-spaces-and-tabs': 'off',
},
overrides: [
{
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended-type-checked'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
},
},
{
files: ['**/env.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off',
},
},
{
files: ['packages/*/__tests__/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
],
};
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ jobs:
- name: Test packages
run: pnpm -r test:coverage

lint:
name: Lint code
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- run: pnpm i
- name: Generate types
working-directory: ./docs
run: pnpm astro sync
- name: Run linter
run: pnpm lint:ci

pa11y:
name: Check for accessibility issues
runs-on: ubuntu-20.04
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"description": "",
"scripts": {
"build:examples": "pnpm --no-bail --workspace-concurrency 1 --filter '@example/*' build",
"lint": "eslint .",
"lint:ci": "eslint . --max-warnings 0",
"size": "size-limit",
"version": "pnpm changeset version && pnpm i --no-frozen-lockfile",
"format": "prettier -w --cache --plugin prettier-plugin-astro ."
Expand All @@ -14,10 +16,15 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@size-limit/file": "^8.2.4",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"astro": "^4.3.5",
"eslint": "^8.53.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"prettier": "^3.0.0",
"prettier-plugin-astro": "^0.13.0",
"size-limit": "^8.2.4"
"size-limit": "^8.2.4",
"typescript": "^5.4.2"
},
"packageManager": "[email protected]",
"size-limit": [
Expand Down
Loading
Loading