Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue): .eslintrc blocks user from commiting #224

Merged
merged 17 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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