Skip to content

Commit

Permalink
Merge pull request #29 from s-group-dev/updates
Browse files Browse the repository at this point in the history
fix(dependencies): migrate to ESLint v9, update all other dependencies
  • Loading branch information
iiroj authored Nov 21, 2024
2 parents 76d2771 + f0acbce commit 85d8ebf
Show file tree
Hide file tree
Showing 24 changed files with 2,600 additions and 2,407 deletions.
3 changes: 0 additions & 3 deletions .commitlintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

59 changes: 0 additions & 59 deletions .eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions .lintstagedrc.mjs

This file was deleted.

3 changes: 3 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
extends: ['@commitlint/config-conventional'],
}
74 changes: 74 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import eslintJs from '@eslint/js'
import pluginJest from 'eslint-plugin-jest'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import reactPlugin from 'eslint-plugin-react'
import hooksPlugin from 'eslint-plugin-react-hooks'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
ignores: ['.swc/**', 'dist/**'],
},
{
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.browser,
...globals.node,
},
},
settings: {
react: {
version: 'detect',
},
},
},
eslintJs.configs.recommended,
reactPlugin.configs.flat.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
eslintPluginPrettierRecommended,
{
plugins: {
/** "eslint-plugin-react-hooks" doesn't work with TypeScript */
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
'react-hooks': hooksPlugin,
'simple-import-sort': simpleImportSort,
},
/** "eslint-plugin-react-hooks" doesn't work with TypeScript */
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
rules: {
/** "eslint-plugin-react-hooks" doesn't work with TypeScript */
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...hooksPlugin.configs.recommended.rules,
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'react/react-in-jsx-scope': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
{
files: ['tests/**/*.(spec|test).*'],
plugins: {
jest: pluginJest,
},
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
},
)
4 changes: 2 additions & 2 deletions jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type MockObjectConstructor = ObjectConstructor & { __definePropertyMocked__?: tr
* Allow module mocks with `@swc/core` enforcing stricter ESM spec.
* @see https://github.com/magic-akari/swc_mut_cjs_exports/issues/103#issuecomment-1926819722
*/
if ((Object as MockObjectConstructor)['__definePropertyMocked__'] !== true) {
;(Object as MockObjectConstructor)['__definePropertyMocked__'] = true
if ((Object as MockObjectConstructor).__definePropertyMocked__ !== true) {
;(Object as MockObjectConstructor).__definePropertyMocked__ = true
const originalDefineProperty = Object.defineProperty
const mutableDefineProperty: ObjectConstructor['defineProperty'] = (obj, prop, attributes) => {
// this is to prevent the error `Cannot redefine property: prototype`; prototype can not be configurable...
Expand Down
3 changes: 1 addition & 2 deletions jest.config.cjs → jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line no-undef
module.exports = {
export default {
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
Expand Down
5 changes: 5 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'*.{js,jsx,mjs}': 'eslint --',
'*.ts': 'eslint --',
'*.tsx': 'eslint --',
}
Loading

0 comments on commit 85d8ebf

Please sign in to comment.