Skip to content

Commit cb1af1f

Browse files
authored
chore: update linters and clean out unnecessary config (#4)
- update linters - removed prettier (i prefer optimizing later.. so in this case not having excess files like the prettier files if they are not used)
1 parent 8c57f6e commit cb1af1f

21 files changed

+599
-347
lines changed

.eslintignore

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
**/node_modules/*
2-
**/out/*
3-
**/.next/*
1+
webpack.*
2+
yarn.lock
3+
*.json
4+
*.md
5+
*.toml
6+
7+
*.css
8+
*.scss
9+
*.js
10+
11+
node_modules/
12+
dist/
13+
public/
14+
.next/

.eslintrc.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2020: true,
5+
},
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:react/recommended',
9+
'plugin:import/typescript',
10+
'plugin:@typescript-eslint/recommended',
11+
],
12+
parser: '@typescript-eslint/parser',
13+
parserOptions: {
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
ecmaVersion: 11,
18+
sourceType: 'module',
19+
project: './tsconfig.json',
20+
},
21+
plugins: [
22+
'import',
23+
'react',
24+
'@typescript-eslint',
25+
],
26+
settings: {
27+
react: {
28+
version: 'detect',
29+
}
30+
},
31+
rules: {
32+
'linebreak-style': [ 'error', 'unix' ],
33+
34+
'@typescript-eslint/no-require-imports': [ 'error' ],
35+
36+
'@typescript-eslint/no-unused-vars': [
37+
'error',
38+
{ argsIgnorePattern: '^_' }
39+
],
40+
41+
// 2 space indentation
42+
'@typescript-eslint/indent': [ 'error', 2 ],
43+
44+
// Style
45+
'quotes': [ 'error', 'single', { avoidEscape: true } ],
46+
47+
// ensures clean diffs, see https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
48+
'comma-dangle': [ 'error', 'always-multiline' ],
49+
50+
// Require all imported dependencies are actually declared in package.json
51+
'import/no-extraneous-dependencies': [
52+
'error',
53+
{
54+
optionalDependencies: false, // Disallow importing optional dependencies (those shouldn't be in use in the project)
55+
peerDependencies: false, // Disallow importing peer dependencies (that aren't also direct dependencies)
56+
},
57+
],
58+
59+
// Require all imported libraries actually resolve (!!required for import/no-extraneous-dependencies to work!!)
60+
'import/no-unresolved': [ 'error' ],
61+
62+
// Require an ordering on all imports
63+
'import/order': ['warn', {
64+
groups: ['builtin', 'external'],
65+
alphabetize: { order: 'asc', caseInsensitive: true },
66+
}],
67+
68+
// Cannot import from the same module twice
69+
'no-duplicate-imports': ['error'],
70+
71+
// Cannot shadow names
72+
'no-shadow': 'off',
73+
'@typescript-eslint/no-shadow': ['error'],
74+
75+
// Required spacing in property declarations (copied from TSLint, defaults are good)
76+
'key-spacing': ['error'],
77+
78+
// Require semicolons
79+
'semi': ['error', 'always'],
80+
81+
// Don't unnecessarily quote properties
82+
'quote-props': ['error', 'consistent-as-needed'],
83+
84+
// No multiple empty lines
85+
'no-multiple-empty-lines': ['error'],
86+
87+
// Max line lengths
88+
'max-len': ['error', {
89+
code: 120,
90+
ignoreUrls: true, // Most common reason to disable it
91+
ignoreStrings: true, // These are not fantastic but necessary for error messages
92+
ignoreTemplateLiterals: true,
93+
ignoreComments: true,
94+
ignoreRegExpLiterals: true,
95+
}],
96+
97+
// One of the easiest mistakes to make
98+
'@typescript-eslint/no-floating-promises': ['error'],
99+
100+
// Don't leave log statements littering the premises!
101+
'no-console': ['error'],
102+
103+
// Useless diff results
104+
'no-trailing-spaces': ['error'],
105+
106+
// Must use foo.bar instead of foo['bar'] if possible
107+
'dot-notation': ['error'],
108+
109+
// Are you sure | is not a typo for || ?
110+
'no-bitwise': ['error'],
111+
112+
// Member ordering
113+
'@typescript-eslint/member-ordering': ['error', {
114+
default: [
115+
'public-static-field',
116+
'public-static-method',
117+
'protected-static-field',
118+
'protected-static-method',
119+
'private-static-field',
120+
'private-static-method',
121+
122+
'field',
123+
124+
// Constructors
125+
'constructor', // = ['public-constructor', 'protected-constructor', 'private-constructor']
126+
127+
// Methods
128+
'method',
129+
],
130+
}],
131+
},
132+
};

.eslintrc.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

.prettierignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Footer(): JSX.Element {
77
made by acm at ucla, with next
88
</div>
99
</footer>
10-
)
10+
);
1111
}
1212

1313
export default Footer;

components/GitHubEvent.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Link from 'next/link'
2-
import React from 'react'
1+
import Link from 'next/link';
2+
import React from 'react';
33

4-
import GitHubEventAction from './GitHubEventAction'
4+
import GitHubEventAction from './GitHubEventAction';
55

66
// TODO(mattxwang): get the official types from the type registry;
77
// see https://github.com/octokit/types.ts
@@ -32,12 +32,8 @@ interface GitHubRepo {
3232
}
3333

3434
function GitHubEvent(props: GitHubEvent): JSX.Element {
35-
const { type, actor, repo, payload } = props
36-
const userLink = !actor.login.includes('[bot]') ? (
37-
<Link href={`https://github.com/${actor.login}`}>{`@${actor.login}`}</Link>
38-
) : (
39-
actor.login
40-
)
35+
const {type, actor, repo, payload} = props;
36+
const userLink = !actor.login.includes('[bot]') ? <Link href={`https://github.com/${actor.login}`}>{`@${actor.login}`}</Link> : actor.login;
4137
return (
4238
<>
4339
{/* <div className="card" style={{marginTop: "20px"}}> */}
@@ -48,7 +44,7 @@ function GitHubEvent(props: GitHubEvent): JSX.Element {
4844
{/* </div> */}
4945
{/* // </div> */}
5046
</>
51-
)
47+
);
5248
}
5349

54-
export default GitHubEvent
50+
export default GitHubEvent;

components/GitHubEventAction.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
// TODO(mattxwang): fix the payload thing to actually use a type, maybe
23
// from the octokit types
34
interface GitHubEventActionProps {
@@ -9,45 +10,45 @@ interface GitHubEventActionProps {
910
// returns a string of form: <verb> <location/type of action> <preposition>
1011
function GitHubEventAction({type, payload}: GitHubEventActionProps): JSX.Element {
1112
const linkProps = {
12-
rel: "noopener noreferrer",
13-
target: "_blank",
14-
}
13+
rel: 'noopener noreferrer',
14+
target: '_blank',
15+
};
1516
const unknown = <span>did a {type} on</span>;
1617
switch(type){
17-
case "CreateEvent":
18-
case "DeleteEvent": {
18+
case 'CreateEvent':
19+
case 'DeleteEvent': {
1920
const target = payload?.ref;
2021
const targetType = payload?.ref_type;
2122
if (!target || !targetType) {
2223
return unknown;
2324
}
24-
const action = type === "CreateEvent"? "created" : "deleted";
25+
const action = type === 'CreateEvent'? 'created' : 'deleted';
2526
return <span>{action} {targetType} <code>{target}</code> in</span>;
2627
}
27-
case "IssueCommentEvent": {
28+
case 'IssueCommentEvent': {
2829
const action = payload?.action;
2930
const issue = payload?.issue;
3031
const issueURL = issue?.html_url;
3132
const issueNum = issue?.number;
3233
if (!action || !issue || !issueURL) {
3334
return unknown;
3435
}
35-
const issueText = issueNum ? `issue #${issueNum}` : "an issue";
36-
const actionStr = action === "created" ? "commented on" : action;
36+
const issueText = issueNum ? `issue #${issueNum}` : 'an issue';
37+
const actionStr = action === 'created' ? 'commented on' : action;
3738
return <span>{actionStr} <a href={issueURL} {...linkProps}>{issueText}</a> in</span>;
3839
}
39-
case "IssuesEvent": {
40+
case 'IssuesEvent': {
4041
const action = payload?.action;
4142
const issue = payload?.issue;
4243
const issueURL = issue?.html_url;
4344
const issueNum = issue?.number;
4445
if (!action || !issue || !issueURL) {
4546
return unknown;
4647
}
47-
const issueText = issueNum ? `issue #${issueNum}` : "an issue";
48+
const issueText = issueNum ? `issue #${issueNum}` : 'an issue';
4849
return <span>{action} <a href={issueURL} {...linkProps}>{issueText}</a> in</span>;
4950
}
50-
case "PullRequestEvent": {
51+
case 'PullRequestEvent': {
5152
const action = payload?.action;
5253
const prNum = payload?.number;
5354
const prURL = payload?.pull_request?.html_url;
@@ -56,20 +57,20 @@ function GitHubEventAction({type, payload}: GitHubEventActionProps): JSX.Element
5657
}
5758
return <span>{action} <a href={prURL} {...linkProps}>pull request #{prNum}</a> in</span>;
5859
}
59-
case "PullRequestReviewEvent": {
60+
case 'PullRequestReviewEvent': {
6061
const action = payload?.action;
6162
const prNum = payload?.pull_request?.number;
6263
const prURL = payload?.pull_request?.html_url;
6364
if (!action || !prNum || !prURL) {
6465
return unknown;
6566
}
66-
const actionStr = action === "created" ? "reviewed" : action;
67+
const actionStr = action === 'created' ? 'reviewed' : action;
6768
return <span>{actionStr} <a href={prURL} {...linkProps}>pull request #{prNum}</a> in</span>;
6869
}
69-
case "PushEvent": {
70+
case 'PushEvent': {
7071
const size = payload?.size; // should this be distinct_size?
7172
const sizeStr = size ? size : '1'; // should we use 'a'?
72-
return <span>pushed {sizeStr} commit{size !== 1 && "s"} to</span>;
73+
return <span>pushed {sizeStr} commit{size !== 1 && 's'} to</span>;
7374
}
7475
default:
7576
return unknown;

components/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Navbar(): JSX.Element {
2525
</div>
2626
</div>
2727
</nav>
28-
)
28+
);
2929
}
3030

3131
export default Navbar;

0 commit comments

Comments
 (0)