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

feat: Introduce eslint and prettier #1

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 13,
"sourceType": "module",
"project": "./tsconfig.json"
},
"extends": [
"airbnb-base",
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
],
"rules": {
"import/prefer-default-export": "off",
"@typescript-eslint/quotes": ["error", "double"],
"@typescript-eslint/no-use-before-define": "off"
}
}
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ci
on: pull_request

defaults:
run:
shell: bash

jobs:
lint-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
- run: npm ci
- run: npm run lint
- run: npm run format-check
- run: npm run build
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 80
}
38 changes: 20 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14046,44 +14046,44 @@ const fs_1 = __nccwpck_require__(7147);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
if (github.context.eventName !== 'pull_request') {
core.setFailed(`This action only supports pull_request event`);
if (github.context.eventName !== "pull_request") {
core.setFailed("This action only supports pull_request event");
return;
}
const token = core.getInput('token');
const token = core.getInput("token");
const octokit = github.getOctokit(token);
const { owner, repo, number } = github.context.issue;
const { data } = yield octokit.rest.pulls.get({
owner: owner,
repo: repo,
owner,
repo,
pull_number: number,
});
if (data.state !== 'open') {
core.info('This pull request is not open');
if (data.state !== "open") {
core.info("This pull request is not open");
return;
}
const configFilePath = core.getInput('config-file-path');
const config = (0, js_yaml_1.load)((0, fs_1.readFileSync)(configFilePath, 'utf8'));
const configFilePath = core.getInput("config-file-path");
const config = (0, js_yaml_1.load)((0, fs_1.readFileSync)(configFilePath, "utf8"));
if (config.ignore && !validateByIgnore(config.ignore, data.title)) {
return;
}
const { data: { files }, } = yield octokit.rest.repos.compareCommits({
owner: owner,
repo: repo,
owner,
repo,
base: data.base.ref,
head: data.head.ref,
});
if (!files) {
core.info('No files changed');
core.info("No files changed");
return;
}
const filenames = files.map((file) => file.filename);
const { users, teams } = getReviewers(filenames, config);
core.info(`User reviewers: ${users}`);
core.info(`Team reviewers: ${teams}`);
octokit.rest.pulls.requestReviewers({
owner: owner,
repo: repo,
core.info(`User reviewers: ${users.join(",")}`);
core.info(`Team reviewers: ${teams.join(",")}`);
yield octokit.rest.pulls.requestReviewers({
owner,
repo,
pull_number: number,
reviewers: Array.from(users),
team_reviewers: Array.from(teams),
Expand All @@ -14107,6 +14107,7 @@ function validateByIgnore(ignore, title) {
isIgnoredByTitle = true;
return true;
}
return false;
});
return !isIgnoredByTitle;
}
Expand Down Expand Up @@ -14137,11 +14138,12 @@ function getReviewers(filenames, config) {
}
return true;
}
return false;
});
});
return { users: Array.from(users), teams: Array.from(teams) };
}
run();
run().then(() => { }, () => { });


/***/ }),
Expand Down
Loading