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

fix: eslint not working #28

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"version": "20.18.0"
},
"ghcr.io/devcontainers-contrib/features/pnpm": {
"version": "9.12.0"
"version": "9.12.1"
},
"ghcr.io/balazs23/devcontainers-features/nx": {
"version": "19.8.4"
"version": "20.0.0"
}
},
"postCreateCommand": "pnpm setup"
Expand Down
17 changes: 15 additions & 2 deletions apps/cli-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// @ts-check

import { baseConfigs, nodeConfigs } from '@organization/eslint-config'
import {
baseConfigs,
createConfig,
nodeConfigs
} from '@organization/eslint-config'

export default [...baseConfigs, ...nodeConfigs]
export default createConfig({
extends: [...baseConfigs, ...nodeConfigs],
files: ['{src,test}/**/*.{ts,js}'],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json', './test/tsconfig.json'],
tsconfigRootDir: import.meta.dirname
}
}
})
8 changes: 4 additions & 4 deletions apps/cli-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "eslint ./src/**/* ./test/**/* --fix",
"lint:check": "eslint ./src/**/* ./test/**/*",
"lint": "eslint --fix",
"lint:check": "eslint",
"format": "prettier . --write",
"format:check": "prettier . --check",
"build": "tsup",
Expand Down Expand Up @@ -57,10 +57,10 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"prettier": "@organization/prettier-config",
"nx": {}
}
14 changes: 12 additions & 2 deletions apps/web-app/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
import {
baseConfigs,
browserConfigs,
reactConfigs
reactConfigs,
createConfig
} from '@organization/eslint-config'

export default [...baseConfigs, ...browserConfigs, ...reactConfigs]
export default createConfig({
extends: [...baseConfigs, ...browserConfigs, ...reactConfigs],
files: ['src/**/*.{ts,tsx,js,jsx}'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname
}
}
})
8 changes: 4 additions & 4 deletions apps/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "eslint ./src/**/* --fix",
"lint:check": "eslint ./src/**/*",
"lint": "eslint --fix",
"lint:check": "eslint",
"format": "prettier . --write",
"format:check": "prettier . --check",
"build": "tsc -b && vite build",
Expand Down Expand Up @@ -43,10 +43,10 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"prettier": "@organization/prettier-config",
"nx": {}
}
12 changes: 10 additions & 2 deletions apps/web-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'

export const App: React.FC = () => {
const [count, setCount] = useState<number>(0)

useEffect(() => {
document.title = `You clicked ${count.toString()} times`
}, [count])

return (
<>
<div>
Expand All @@ -18,7 +22,11 @@ export const App: React.FC = () => {
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
<button
onClick={() => {
setCount((count) => count + 1)
}}
>
count is {count}
</button>
<p>
Expand Down
8 changes: 7 additions & 1 deletion apps/web-app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { createRoot } from 'react-dom/client'
import App from './App'
import './index.css'

createRoot(document.getElementById('root')!).render(
const root = document.getElementById('root')

if (root === null) {
throw new Error('No root element')
}

createRoot(root).render(
<StrictMode>
<App />
</StrictMode>
Expand Down
1 change: 1 addition & 0 deletions apps/web-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@organization/tsconfig",
"compilerOptions": {
"baseUrl": "./",
Expand Down
9 changes: 5 additions & 4 deletions devpacks/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"devDependencies": {
"@organization/prettier-config": "workspace:*",
"@eslint/js": "^9.12.0",
"@organization/prettier-config": "workspace:*",
"@organization/tsconfig": "workspace:*",
"@organization/tsup": "workspace:*",
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__js": "^8.42.3",
"@types/node": "^22.7.4",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.10.0",
"rimraf": "^6.0.1",
"tsup": "^8.3.0",
"typescript-eslint": "^8.8.0"
"typescript-eslint": "^8.8.1"
},
"nx": {},
"prettier": "@organization/prettier-config"
Expand Down
48 changes: 22 additions & 26 deletions devpacks/eslint-config/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ import tseslint from 'typescript-eslint'
import prettier from 'eslint-config-prettier'
import { type EsConfig } from './types'

const strictTypeChecked = tseslint.configs.strictTypeChecked
const stylisticTypeChecked = tseslint.configs.stylisticTypeChecked
export const createConfig: typeof tseslint.config = tseslint.config

export const baseConfigs: EsConfig = [
{
files: ['**/*.{js,mjs,cjs,ts,tsx,jsx}'],
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/coverage/**'
],
linterOptions: {
noInlineConfig: true
},
languageOptions: {
parserOptions: {
project: ['./tsconfig.json', './test/tsconfig.json']
},
ecmaVersion: 'latest',
sourceType: 'module'
}
export const baseConfigs: EsConfig = createConfig({
extends: [
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
prettier
],
linterOptions: {
noInlineConfig: true
},
eslint.configs.recommended,
...strictTypeChecked,
...stylisticTypeChecked,
prettier
]
languageOptions: {
/* enable if typechecking is not working */
// parserOptions: {
// project: ['./tsconfig.json'],
// tsconfigRootDir: baseDir,
// ecmaVersion: 'latest',
// sourceType: 'module',
// },
sourceType: 'module',
ecmaVersion: 'latest'
}
})
13 changes: 6 additions & 7 deletions devpacks/eslint-config/src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import globals from 'globals'
import tseslint from 'typescript-eslint'
import { EsConfig } from './types'

export const browserConfigs: EsConfig = [
{
languageOptions: {
globals: {
...globals.browser
}
export const browserConfigs: EsConfig = tseslint.config({
languageOptions: {
globals: {
...globals.browser
}
}
]
})
13 changes: 6 additions & 7 deletions devpacks/eslint-config/src/node.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import globals from 'globals'
import { EsConfig } from './types'
import tseslint from 'typescript-eslint'

export const nodeConfigs: EsConfig = [
{
languageOptions: {
globals: {
...globals.node
}
export const nodeConfigs: EsConfig = tseslint.config({
languageOptions: {
globals: {
...globals.node
}
}
]
})
27 changes: 13 additions & 14 deletions devpacks/eslint-config/src/react.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { EsConfig } from './types'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export const reactConfigs: EsConfig = [
{
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true }
]
}
export const reactConfigs: EsConfig = tseslint.config({
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true }
]
}
]
})
4 changes: 2 additions & 2 deletions devpacks/eslint-config/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { type Config } from 'typescript-eslint'
import tseslint from 'typescript-eslint'

export type EsConfig = Awaited<Config>
export type EsConfig = ReturnType<typeof tseslint.config>
4 changes: 2 additions & 2 deletions devpacks/prettier-config/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"devDependencies": {
"prettier": "3.3.3",
"rimraf": "^6.0.1"
Expand Down
17 changes: 15 additions & 2 deletions devpacks/scripts/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// @ts-check

import { baseConfigs, nodeConfigs } from '@organization/eslint-config'
import {
baseConfigs,
createConfig,
nodeConfigs
} from '@organization/eslint-config'

export default [...baseConfigs, ...nodeConfigs]
export default createConfig({
extends: [...baseConfigs, ...nodeConfigs],
files: ['{src,test}/**/*.{ts,js}'],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json', './test/tsconfig.json'],
tsconfigRootDir: import.meta.dirname
}
}
})
8 changes: 4 additions & 4 deletions devpacks/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "eslint ./src/**/* ./test/**/* --fix",
"lint:check": "eslint ./src/**/* ./test/**/*",
"lint": "eslint --fix",
"lint:check": "eslint",
"format": "prettier . --write",
"format:check": "prettier . --check",
"build": "tsup",
Expand Down Expand Up @@ -59,10 +59,10 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"prettier": "@organization/prettier-config",
"nx": {}
}
4 changes: 2 additions & 2 deletions devpacks/tsconfig/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"devDependencies": {
"rimraf": "^6.0.1",
"typescript": "^5.6.2"
Expand Down
4 changes: 2 additions & 2 deletions devpacks/tsup/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"license": "MIT",
"engines": {
"node": "20.18.0",
"pnpm": "9.12.0"
"pnpm": "9.12.1"
},
"engineStrict": true,
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.12.1",
"nx": {}
}
Loading