Skip to content

Commit

Permalink
chore(setup): flat config esm
Browse files Browse the repository at this point in the history
  • Loading branch information
driimus committed Apr 8, 2024
1 parent 537316d commit 4884fc1
Show file tree
Hide file tree
Showing 13 changed files with 872 additions and 473 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

63 changes: 0 additions & 63 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"jest.jestCommandLine": "pnpm run test"
"eslint.experimental.useFlatConfig": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Cristian Petre
Copyright (c) 2024 Cristian Petre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
93 changes: 93 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import eslint from '@eslint/js';
import prettier from 'eslint-plugin-prettier/recommended';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import unicorn from 'eslint-plugin-unicorn';
import vitest from 'eslint-plugin-vitest';
import tsEslint from 'typescript-eslint';

export default tsEslint.config(
{
ignores: [
'dist',
'coverage',
'tests/fixtures',
'*.d.ts',
'eslint.config.js',
'vitest.config.ts',
],
},
eslint.configs.recommended,
...tsEslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// TODO: re-enable after flat config support
// 'import/first': 'error',
// 'import/newline-after-import': 'error',
// 'import/no-duplicates': 'error',
},
},
unicorn.configs['flat/recommended'],
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tsEslint.plugin,
},
rules: {
'prefer-const': ['error', { destructuring: 'all' }],
'unicorn/filename-case': 'off',
'unicorn/prevent-abbreviations': 'warn',
'unicorn/no-null': 'off',
'unicorn/no-useless-switch-case': 'error',
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksConditionals: true,
},
],
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
},
},
{
files: ['**/*.test.ts'],
plugins: {
vitest,
},
rules: {
...vitest.configs.recommended.rules,
'@typescript-eslint/no-unsafe-assignment': 'off',
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
},
prettier,
);
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prepublishOnly": "tsc",
"test": "vitest run",
"generate-fixtures": "openapi-generator-cli generate",
"lint": "eslint --ext .ts .",
"format": "eslint --fix --ext .ts .",
"lint": "eslint",
"format": "eslint --fix",
"ci:version": "changeset version",
"ci:publish": "changeset publish"
},
Expand All @@ -41,20 +41,22 @@
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@openapitools/openapi-generator-cli": "^2.5.2",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@tsconfig/node20": "^20.1.4",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-unicorn": "^52.0.0",
"eslint-plugin-vitest": "^0.2.8",
"eslint-plugin-vitest": "0.4.2-beta.5",
"fancy-set": "^0.1.5",
"jest-extended": "^4.0.1",
"lint-staged": "^15.0.0",
"prettier": "^3.0.1",
"typescript": "^5.1.6",
"typescript-eslint": "^7.5.0",
"vitest": "^1.0.0"
},
"packageManager": "[email protected]",
Expand Down
Loading

0 comments on commit 4884fc1

Please sign in to comment.