Skip to content

Commit 6a578ba

Browse files
authored
Merge pull request #48 from KotlinFoundation/KTL-1241-lint
KTL-1241 chore: added eslint&prettier, run them on pre-commit
2 parents d90d244 + ee0e5b7 commit 6a578ba

File tree

97 files changed

+4514
-2886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4514
-2886
lines changed

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
10+
# Change these settings to your own preference
11+
indent_style = space
12+
indent_size = 2
13+
14+
# We recommend you to keep these unchanged
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
public
3+
*.css.d.ts

.eslintrc.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:react/recommended',
10+
'plugin:prettier/recommended',
11+
],
12+
overrides: [
13+
{
14+
env: {
15+
node: true,
16+
},
17+
files: ['.eslintrc.{js,cjs}'],
18+
parserOptions: {
19+
sourceType: 'script',
20+
},
21+
},
22+
],
23+
parser: '@typescript-eslint/parser',
24+
parserOptions: {
25+
project: 'tsconfig.json',
26+
ecmaVersion: 'latest',
27+
sourceType: 'module',
28+
},
29+
settings: {
30+
react: {
31+
version: 'detect',
32+
},
33+
},
34+
plugins: ['@typescript-eslint', 'react', 'prettier', 'import', 'react-hooks'],
35+
rules: {
36+
indent: 'off',
37+
'linebreak-style': ['error', 'unix'],
38+
quotes: ['error', 'single'],
39+
semi: ['error', 'always'],
40+
curly: ['error', 'all'],
41+
'react/react-in-jsx-scope': 'off',
42+
'import/order': ['error', { alphabetize: { order: 'asc' } }],
43+
'react-hooks/rules-of-hooks': 'error',
44+
'react-hooks/exhaustive-deps': 'warn',
45+
},
46+
ignorePatterns: ['*.js', '*.mjs'],
47+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
public
44
.idea
55
.DS_Store
6+
*.css.d.ts

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn run lint-staged

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'es5',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 2,
7+
};

lint-staged.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
"src/**/**/*.{ts,tsx}": [
3+
"eslint --fix",
4+
() => "tsc --noEmit"
5+
],
6+
"src/**/**/*.{ts,tsx,css,scss}": [
7+
"prettier --write"
8+
]
9+
}

package.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
"gatsby"
88
],
99
"scripts": {
10-
"start": "gatsby develop --port 8082",
10+
"start": "gatsby develop --port 8082 & tcm -w -c src",
1111
"build": "gatsby build --prefix-paths",
1212
"serve": "gatsby serve",
13-
"clean": "gatsby clean"
13+
"clean": "gatsby clean",
14+
"lint": "eslint --ext src/**/**/*.{ts,tsx} --quiet",
15+
"lint:fix": "eslint --fix --ext src/**/**/*.{ts,tsx} --quiet",
16+
"prettier": "prettier --write 'src/**/**/*.{ts,tsx,css,scss}'",
17+
"generate-css-types": "tcm -c src",
18+
"lint-staged": "lint-staged",
19+
"prepare": "husky install"
1420
},
1521
"dependencies": {
1622
"@csstools/postcss-global-data": "^1.0.3",
@@ -48,10 +54,17 @@
4854
"@babel/core": "^7.21.3",
4955
"@mdx-js/react": "^2.3.0",
5056
"@types/react-helmet": "^6.1.6",
57+
"@typescript-eslint/eslint-plugin": "^6.12.0",
58+
"@typescript-eslint/parser": "^6.12.0",
5159
"babel-eslint": "^10.1.0",
5260
"babel-preset-gatsby": "^3.7.0",
5361
"core-js": "^3.29.1",
54-
"eslint": "^8.36.0",
62+
"eslint": "^8.54.0",
63+
"eslint-config-prettier": "^9.0.0",
64+
"eslint-plugin-import": "^2.29.0",
65+
"eslint-plugin-prettier": "^5.0.1",
66+
"eslint-plugin-react": "^7.33.2",
67+
"eslint-plugin-react-hooks": "^4.6.0",
5568
"gatsby": "5",
5669
"gatsby-plugin-image": "^3.7.0",
5770
"gatsby-plugin-manifest": "^5.7.0",
@@ -65,8 +78,12 @@
6578
"gatsby-transformer-remark": "^6.7.0",
6679
"gatsby-transformer-sharp": "^5.7.0",
6780
"glob": "^10.2.1",
81+
"husky": "^8.0.3",
82+
"lint-staged": "^15.1.0",
6883
"postcss": "^8.4.21",
84+
"prettier": "^3.1.0",
6985
"prop-types": "^15.7.2",
86+
"typed-css-modules": "^0.8.1",
7087
"typescript": "^4.9.5",
7188
"typescript-plugin-css-modules": "^4.2.3"
7289
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.br {
2-
@media (--ktl-mm) {
3-
display: none;
4-
}
2+
@media (--ktl-mm) {
3+
display: none;
4+
}
55
}

src/components/ContactUs/index.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import { CtaBlock } from "@jetbrains/kotlin-web-site-ui/out/components/cta-block-v2";
1+
import { CtaBlock } from '@jetbrains/kotlin-web-site-ui/out/components/cta-block-v2';
22

3-
import {Link} from "../Link";
3+
import { Link } from '../Link';
44

5-
import * as styles from "./contactUs.module.css";
5+
import * as styles from './contactUs.module.css';
66

77
const contactEmail = '[email protected]';
88

99
export function ContactUs() {
10-
return (
11-
<CtaBlock
12-
topTitle={<>Still have questions? <br className={styles.br}/>Contact us!</>}
13-
classMainTitle="ktf-h2 ktf-h3--ts"
14-
mainTitle={
15-
<Link href={`mailto:${contactEmail}`} mode="clear">
16-
{contactEmail}
17-
</Link>
18-
}
19-
/>
20-
);
10+
return (
11+
<CtaBlock
12+
topTitle={
13+
<>
14+
Still have questions? <br className={styles.br} />
15+
Contact us!
16+
</>
17+
}
18+
classMainTitle="ktf-h2 ktf-h3--ts"
19+
mainTitle={
20+
<Link href={`mailto:${contactEmail}`} mode="clear">
21+
{contactEmail}
22+
</Link>
23+
}
24+
/>
25+
);
2126
}

0 commit comments

Comments
 (0)