-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Emilien Escalle <[email protected]>
- Loading branch information
Showing
32 changed files
with
2,237 additions
and
2,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ node_modules/ | |
dist/ | ||
coverage/ | ||
**/yarn-error.log | ||
.nx/cache | ||
.nx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"description": "Opinionated and advisable packages to configure tools to develop a Typescript project", | ||
"main": "index.js", | ||
"repository": "[email protected]:escemi-tech/ts-dev-tools.git", | ||
"author": "Emilien Escalle <emilien.escalle@escemi.com>", | ||
"author": "ESCEMI <contact@escemi.com>", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
|
@@ -18,9 +18,9 @@ | |
"unlink": "lerna exec yarn unlink" | ||
}, | ||
"devDependencies": { | ||
"lerna": "^8.0.0", | ||
"rimraf": "^5.0.0", | ||
"typescript": "^5.0.2" | ||
"lerna": "^8.1.8", | ||
"rimraf": "^6.0.1", | ||
"typescript": "^5.5.4" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"version": "1.0.0" | ||
"version": "1.0.0", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Must be duplicated "packages/core/eslint.config.mjs" and "packages/core/src/eslint-plugin-ts-dev-tools/index.ts" files | ||
|
||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
import eslintConfigJest from "eslint-plugin-jest"; | ||
|
||
export default [ | ||
{ languageOptions: { globals: globals.node } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
eslintConfigPrettier, | ||
{ | ||
languageOptions: { globals: globals.jest }, | ||
files: ["**/src/**/__tests__/**/*.[jt]s?(x)", "**/src/**/?(*.)+(spec|test)?(.*).+(ts|tsx|js)"], | ||
...eslintConfigJest.configs["flat/recommended"], | ||
rules: { | ||
...eslintConfigJest.configs["flat/recommended"].rules, | ||
"jest/prefer-expect-assertions": "off", | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Must be duplicated "packages/core/eslint.config.mjs" and "packages/react/eslint.config.mjs" files | ||
|
||
import globals from "globals"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const pluginJs = require("@eslint/js"); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const eslintConfigPrettier = require("eslint-config-prettier"); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const eslintConfigJest = require("eslint-plugin-jest"); | ||
|
||
export default [ | ||
{ languageOptions: { globals: globals.node } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
eslintConfigPrettier, | ||
{ | ||
languageOptions: { globals: globals.jest }, | ||
files: ["**/src/**/__tests__/**/*.[jt]s?(x)", "**/src/**/?(*.)+(spec|test)?(.*).+(ts|tsx|js)"], | ||
...eslintConfigJest.configs["flat/recommended"], | ||
rules: { | ||
...eslintConfigJest.configs["flat/recommended"].rules, | ||
"jest/prefer-expect-assertions": "off", | ||
}, | ||
}, | ||
]; |
40 changes: 40 additions & 0 deletions
40
packages/core/src/install/migrations/20240412185500-eslint-config.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FileService } from "../../services/FileService"; | ||
import { PackageJson } from "../../services/PackageJson"; | ||
import { | ||
createTestProjectDirWithFixtures, | ||
removeTestProjectDir, | ||
restorePackageJson, | ||
} from "../../tests/project"; | ||
import { up } from "./20240412185500-eslint-config"; | ||
|
||
describe("Migration 20240412185500-eslint-config", () => { | ||
let testProjectDir: string; | ||
|
||
beforeAll(() => { | ||
testProjectDir = createTestProjectDirWithFixtures(__filename); | ||
}); | ||
|
||
afterAll(() => { | ||
removeTestProjectDir(__filename); | ||
}); | ||
|
||
describe("Up", () => { | ||
afterEach(() => { | ||
restorePackageJson(__filename); | ||
}); | ||
|
||
it("should apply migration", async () => { | ||
await up(testProjectDir); | ||
|
||
const packageJsonContent = PackageJson.fromDirPath(testProjectDir).getContent(); | ||
expect(packageJsonContent).toMatchSnapshot(); | ||
|
||
const eslintConfigFilePath = `${testProjectDir}/eslint.config.mjs`; | ||
|
||
expect(FileService.fileExists(eslintConfigFilePath)).toBe(true); | ||
|
||
const eslintConfigContent = FileService.getFileContent(eslintConfigFilePath); | ||
expect(eslintConfigContent).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/core/src/install/migrations/20240412185500-eslint-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FileService } from "../../services/FileService"; | ||
import { MigrationUpFunction } from "../../services/MigrationsService"; | ||
import { PackageJson } from "../../services/PackageJson"; | ||
|
||
export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promise<void> => { | ||
const packageJson = PackageJson.fromDirPath(absoluteProjectDir); | ||
|
||
const packageJsonContent = packageJson.getContent(); | ||
delete packageJsonContent.eslintConfig; | ||
packageJson.setContent(packageJsonContent); | ||
|
||
const eslintConfigFilePath = `${absoluteProjectDir}/eslint.config.mjs`; | ||
if (FileService.fileExists(eslintConfigFilePath)) { | ||
return; | ||
} | ||
|
||
FileService.putFileContent( | ||
eslintConfigFilePath, | ||
`import tsDevToolsCore from "@ts-dev-tools/core/dist/eslint-plugin-ts-dev-tools/index.js"; | ||
export default tsDevToolsCore; | ||
` | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.