Skip to content

Commit

Permalink
feat(core): add eslint ignore
Browse files Browse the repository at this point in the history
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
  • Loading branch information
neilime committed Mar 29, 2024
1 parent a94d29c commit 99cffbd
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 12 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/__snapshots__/core.spec.e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Applying migration "core - 20201024173398-init"...
Migration "core - 20201024173398-init" applied!
Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!
Symlinking dev dependencies...
Symlinking dev dependencies done!
Checking for duplicate dev dependencies...
Expand All @@ -24,6 +26,8 @@ Applying migration "core - 20201024173398-init"...
Migration "core - 20201024173398-init" applied!
Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!
Symlinking dev dependencies...
- Symlinking eslint-config-prettier
- Symlinking eslint-plugin-import
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core.spec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe(`E2E - ${packageToTest}`, () => {
beforeEach(async () => {
testSimpleProjectDir = join(testProjectDir, "simple-project");
await safeExec(testProjectDir, `cp -r ${testProjectTmpDir} ${testSimpleProjectDir}`);
await safeExec(testSimpleProjectDir, `rm -f package-lock.json`);
await safeExec(testSimpleProjectDir, `yarn install`);
}, 200000);

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/install/migrations/20201024173398-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promi
},
};

const packageManager = PackageManagerService.detectPackageManager(absoluteProjectDir);

const scripts = {
build: "tsc --noEmit",
format: "prettier --write '**/*.js'",
lint: 'eslint "src/**/*.{ts,tsx}"',
jest: "jest --detectOpenHandles --forceExit",
test: "yarn jest --maxWorkers=50%",
"test:watch": "yarn jest --watch --maxWorkers=25%",
"test:cov": "yarn jest --coverage",
"test:ci": "yarn test:cov --runInBand",
test: `${packageManager} run jest --maxWorkers=50%`,
"test:watch": `${packageManager} run jest --watch --maxWorkers=25%`,
"test:cov": `${packageManager} run jest --coverage`,
"test:ci": `${packageManager} run test:cov --runInBand`,
prepare: `${PROJECT_NAME} install`,
};

Expand All @@ -87,8 +89,6 @@ export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promi
const isGitRepository = await GitService.isGitRepository(absoluteProjectDir);

if (isGitRepository) {
const packageManager = PackageManagerService.detectPackageManager(absoluteProjectDir);

const gitHooks = {
"pre-commit": "npx --no-install lint-staged && npx --no-install pretty-quick --staged",
"commit-msg": "npx --no-install commitlint --edit $1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PackageJson } from "../../services/PackageJson";
import {
createTestProjectDirWithFixtures,
removeTestProjectDir,
restorePackageJson,
} from "../../tests/project";
import { up } from "./20240329200200-eslint-ignore";

describe("Migration 20240329200200-eslint-ignore", () => {
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();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MigrationUpFunction } from "../../services/MigrationsService";
import { PackageJson } from "../../services/PackageJson";

export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promise<void> => {
const eslintConfig = {
ignorePatterns: ["dist", "node_modules"],
};

const packageJson = PackageJson.fromDirPath(absoluteProjectDir);
packageJson.merge({
eslintConfig,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ exports[`Migration 20201024173398-init Up should apply migration 1`] = `
"jest": "jest --detectOpenHandles --forceExit",
"lint": "eslint "src/**/*.{ts,tsx}"",
"prepare": "ts-dev-tools install",
"test": "yarn jest --maxWorkers=50%",
"test:ci": "yarn test:cov --runInBand",
"test:cov": "yarn jest --coverage",
"test:watch": "yarn jest --watch --maxWorkers=25%",
"test": "npm run jest --maxWorkers=50%",
"test:ci": "npm run test:cov --runInBand",
"test:cov": "npm run jest --coverage",
"test:watch": "npm run jest --watch --maxWorkers=25%",
},
"version": "1.0.0",
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Migration 20240329200200-eslint-ignore Up should apply migration 1`] = `
{
"eslintConfig": {
"ignorePatterns": [
"dist",
"node_modules",
],
},
"version": "1.0.0",
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

exports[`MigrationsService executeMigrations should execute migrations when no available migrations exist after given version 1`] = `
"Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!"
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!"
`;

exports[`MigrationsService executeMigrations should execute migrations when no version is provided 1`] = `
"Applying migration "core - 20201024173398-init"...
Migration "core - 20201024173398-init" applied!
Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!"
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!"
`;
4 changes: 4 additions & 0 deletions packages/react/src/__snapshots__/react.spec.e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Applying migration "react - 20201111162698-init"...
Migration "react - 20201111162698-init" applied!
Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!
Symlinking dev dependencies...
Symlinking dev dependencies done!
Checking for duplicate dev dependencies...
Expand All @@ -28,6 +30,8 @@ Applying migration "react - 20201111162698-init"...
Migration "react - 20201111162698-init" applied!
Applying migration "core - 20220617100200-prettier-cache"...
Migration "core - 20220617100200-prettier-cache" applied!
Applying migration "core - 20240329200200-eslint-ignore"...
Migration "core - 20240329200200-eslint-ignore" applied!
Symlinking dev dependencies...
- Symlinking ts-jest
Symlinking dev dependencies done!
Expand Down

0 comments on commit 99cffbd

Please sign in to comment.