Skip to content

Commit

Permalink
fix: fix eslint cannot lint when commit
Browse files Browse the repository at this point in the history
  • Loading branch information
khoilen committed Jan 4, 2025
1 parent a98dc01 commit 23b73a1
Show file tree
Hide file tree
Showing 9 changed files with 695 additions and 89 deletions.
34 changes: 0 additions & 34 deletions .eslintrc.json

This file was deleted.

6 changes: 5 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
npx lint-staged --concurrent false --relative
# .husky/pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{
"importOrder": [
"^@core/(.*)$",
"^@server/(.*)$",
"^@ui/(.*)$",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderSideEffects": true,
"importOrderCaseInsensitive": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"semi": false,
"trailingComma": "all",
"arrowParens": "always",
Expand Down
6 changes: 3 additions & 3 deletions apps/nt-stylesheet/themes/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ThemeConfig } from 'tailwindcss/types/config'

import { backgroundColor, boxShadow, colors } from './colors'
import { fontFamily, fontWeight } from './font'
import { gap, spacing } from './spacing'

import { ThemeConfig } from 'tailwindcss/types/config'
import { borderRadius } from './radius'
import { gap, spacing } from './spacing'

const theme: Partial<ThemeConfig & { extend: Partial<ThemeConfig> }> =
{
Expand Down
64 changes: 64 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { FlatCompat } from '@eslint/eslintrc'
import nxEslintPlugin from '@nx/eslint-plugin'
import typescriptEslintPlugin from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
import prettierPlugin from 'eslint-plugin-prettier'

const compat = new FlatCompat({
baseConfig: {
plugins: ['@typescript-eslint', '@nx', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@nx/recommended',
'plugin:prettier/recommended',
],
},
})

export default [
{
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': typescriptEslintPlugin,
'@nx': nxEslintPlugin,
prettier: prettierPlugin,
},
ignores: [
'apps/**/coverage/**',
'apps/**/dist/**',
'apps/**/.nx/**',
],
rules: {
'brace-style': ['error', '1tbs'],
semi: ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
...compat.config({
overrides: [
{
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
},
],
}),
]
11 changes: 5 additions & 6 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
'{apps,!apps/dist}/**/*.{ts,tsx}': (files) => {
return `nx affected --target=typecheck --files=${files.join(',')}`
'{apps}/**/*.{js,ts,jsx,tsx,json,css,scss,md}': (files) => {
return [
`prettier --write ${files.join(' ')}`,
`pnpm eslint . --fix`,
]
},
'{apps,!apps/dist}/**/*.{js,ts,jsx,tsx,json}': [
(files) => `nx affected:lint --files=${files.join(',')}`,
(files) => `nx format:write --files=${files.join(',')}`,
],
}
5 changes: 4 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
"inputs": [
"default",
"{workspaceRoot}/.eslint.config.mjs"
]
}
},
"namedInputs": {
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
"lint-staged": "13.2.3",
"nx": "^20.0.1",
"prettier": "3.0.1",
"semantic-release": "^24.2.1"
"semantic-release": "^24.2.1",
"@nx/eslint-plugin": "^20.3.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1"
},
"pnpm": {
"overrides": {
Expand Down
Loading

0 comments on commit 23b73a1

Please sign in to comment.