Skip to content

Commit

Permalink
fix(vue): .eslintrc blocks user from commiting (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lakhdar authored May 18, 2021
1 parent 5a35471 commit c8d9de0
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 50 deletions.
19 changes: 19 additions & 0 deletions packages/cli-e2e/__tests__/angular.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {EOL} from 'os';
import {ProcessManager} from '../utils/processManager';
import {Terminal} from '../utils/terminal/terminal';
import {BrowserConsoleInterceptor} from '../utils/browserConsoleInterceptor';
import {commitProject, undoCommit} from '../utils/git';

describe('ui:create:angular', () => {
let browser: Browser;
Expand Down Expand Up @@ -125,6 +126,11 @@ describe('ui:create:angular', () => {
});

afterAll(async () => {
await undoCommit(
serverProcessManager,
getProjectPath(projectName),
projectName
);
await serverProcessManager.killAllProcesses();
}, 5e3);

Expand Down Expand Up @@ -179,6 +185,19 @@ describe('ui:create:angular', () => {
expect(interceptedRequests.some(isSearchRequest)).toBeTruthy();
});
});

it('should be commited without lint-stage errors', async () => {
const eslintErrorSpy = jest.fn();

commitProject(
serverProcessManager,
getProjectPath(projectName),
projectName,
eslintErrorSpy
);

expect(eslintErrorSpy).not.toBeCalled();
}, 10e3);
});

describe('when the required environment variables are missing', () => {
Expand Down
21 changes: 20 additions & 1 deletion packages/cli-e2e/__tests__/react.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ProcessManager} from '../utils/processManager';
import {Terminal} from '../utils/terminal/terminal';
import {deactivateEnvironmentFile, restoreEnvironmentFile} from '../utils/file';
import {BrowserConsoleInterceptor} from '../utils/browserConsoleInterceptor';
import {commitProject, undoCommit} from '../utils/git';

describe('ui:create:react', () => {
let browser: Browser;
Expand Down Expand Up @@ -110,12 +111,17 @@ describe('ui:create:react', () => {
});

afterAll(async () => {
await undoCommit(
serverProcessManager,
getProjectPath(projectName),
projectName
);
await serverProcessManager.killAllProcesses();
}, 5e3);

it('should not contain console errors nor warnings', async () => {
await page.goto(searchPageEndpoint, {
waitUntil: 'networkidle0',
waitUntil: 'networkidle2',
});

expect(consoleInterceptor.interceptedMessages).toEqual([]);
Expand Down Expand Up @@ -164,6 +170,19 @@ describe('ui:create:react', () => {
expect(interceptedRequests.some(isSearchRequest)).toBeTruthy();
});
});

it('should be commited without lint-stage errors', async () => {
const eslintErrorSpy = jest.fn();

commitProject(
serverProcessManager,
getProjectPath(projectName),
projectName,
eslintErrorSpy
);

expect(eslintErrorSpy).not.toBeCalled();
}, 10e3);
});

describe('when the required environment variables are missing', () => {
Expand Down
21 changes: 20 additions & 1 deletion packages/cli-e2e/__tests__/vue.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {ProcessManager} from '../utils/processManager';
import {deactivateEnvironmentFile, restoreEnvironmentFile} from '../utils/file';
import {Terminal} from '../utils/terminal/terminal';
import {BrowserConsoleInterceptor} from '../utils/browserConsoleInterceptor';
import {commitProject, undoCommit} from '../utils/git';

describe('ui:create:vue', () => {
let browser: Browser;
Expand Down Expand Up @@ -123,12 +124,17 @@ describe('ui:create:vue', () => {
});

afterAll(async () => {
await undoCommit(
serverProcessManager,
getProjectPath(projectName),
projectName
);
await serverProcessManager.killAllProcesses();
}, 5e3);

it('should not contain console errors nor warnings', async () => {
await page.goto(searchPageEndpoint, {
waitUntil: 'networkidle0',
waitUntil: 'networkidle2',
});

expect(consoleInterceptor.interceptedMessages).toEqual([]);
Expand Down Expand Up @@ -177,6 +183,19 @@ describe('ui:create:vue', () => {
expect(interceptedRequests.some(isSearchRequest)).toBeTruthy();
});
});

it('should be commited without lint-stage errors', async () => {
const eslintErrorSpy = jest.fn();

commitProject(
serverProcessManager,
getProjectPath(projectName),
projectName,
eslintErrorSpy
);

expect(eslintErrorSpy).not.toBeCalled();
}, 10e3);
});

describe('when starting the server', () => {
Expand Down
56 changes: 56 additions & 0 deletions packages/cli-e2e/utils/git.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {ProcessManager} from './processManager';
import {DoCallback} from './terminal/do';
import {Terminal} from './terminal/terminal';

export const commitProject = async (
processManager: ProcessManager,
pathToRepo: string,
projectName: string,
errorCallback: DoCallback
) => {
const gitAddTerminal = new Terminal(
'git',
['add', '.'],
{cwd: pathToRepo},
processManager,
`add-${projectName}`
);

await gitAddTerminal.when('exit').on('process').do().once();

const gitCommitTerminal = new Terminal(
'git',
['commit', '-m', '"e2e first commit"'],
{cwd: pathToRepo},
processManager,
`commit-${projectName}`
);

const gitCommitExitCondition = gitCommitTerminal
.when('exit')
.on('process')
.do()
.once();

await gitCommitTerminal
.when(/ \d+ problems \(\d+ errors, \d+ warnings\)/)
.on('stderr')
.do(errorCallback)
.until(gitCommitExitCondition);
};

export const undoCommit = async (
processManager: ProcessManager,
pathToRepo: string,
projectName: string
) => {
const gitTerminal = new Terminal(
'git',
['reset', 'HEAD~'],
{cwd: pathToRepo},
processManager,
`undo-${projectName}`
);

await gitTerminal.when('exit').on('process').do().once();
};
6 changes: 0 additions & 6 deletions packages/search-token-server/.eslintrc

This file was deleted.

16 changes: 16 additions & 0 deletions packages/search-token-server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"es6": true,
"node": true,
"jest": true
},

"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"root": true
}
2 changes: 1 addition & 1 deletion packages/search-token-server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = express();

app.use(express.json());

app.get<{}, any, {token: string}>(
app.get<Record<string, string>, any, {token: string}>(
'/token',
environmentCheck,
ensureTokenGenerated,
Expand Down
Loading

0 comments on commit c8d9de0

Please sign in to comment.