Skip to content

Commit aceb221

Browse files
committed
Add hypetech dev prefered eslint rules
0 parents  commit aceb221

File tree

8 files changed

+3945
-0
lines changed

8 files changed

+3945
-0
lines changed

.github/workflows/npm-publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-npm:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Get package version
17+
id: package-version
18+
uses: martinbeentjes/[email protected]
19+
- name: Setup node environment
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18.x'
23+
registry-url: https://registry.npmjs.org
24+
- run: npm ci
25+
- name: Publish to NPM
26+
run: npm publish --provenance --access public
27+
env:
28+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
29+
- name: Collect release notes
30+
id: collect-release-notes
31+
run: |
32+
echo "::group::Prepare release notes"
33+
RELEASE_NOTES=$(awk -v ver=${{ steps.package-version.outputs.current-version }} '/^## \[/ { if ($2 == "["ver"]") { p=1 } else { p=0 } } p { print }' CHANGELOG.md | tail -n +3)
34+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
35+
echo "$RELEASE_NOTES" >> $GITHUB_ENV
36+
echo "EOF" >> $GITHUB_ENV
37+
echo "::endgroup::"
38+
- name: Create Release Tag
39+
id: create-release
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
tag_name: ${{ steps.package-version.outputs.current-version }}
43+
body: ${{ env.RELEASE_NOTES }}
44+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [1.0.0] - 2023-08-21
6+
7+
### Added
8+
9+
- ESlint configuration according to HypeTech Frontend Coding Standards.
10+
- Install documentation
11+
- Changes changelog
12+
- Actions release workflow

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 HypeTech
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# HypeTech - eslint-config
2+
3+
The official HypeTech eslint configuration, part of the Frontend Coding Standards.
4+
5+
## Installation
6+
7+
The configuration can be installed via your preferred package manager.
8+
9+
With PNPM (preferred):
10+
11+
```bash
12+
pnpm add @hypetech/eslint-config -D
13+
```
14+
15+
With Yarn:
16+
17+
```bash
18+
yarn add -D @hypetech/eslint-config
19+
```
20+
21+
With NPM:
22+
23+
```bash
24+
npm install --dev @hypetech/prettier-config
25+
```
26+
27+
To inform eslint of this configuration, you have to add the `eslint` property to your `package.json` file:
28+
29+
```json
30+
"eslintConfig": {
31+
"extends": "@hypetech/eslint-config"
32+
}
33+
```
34+
35+
Instead of manually editing your `package.json`, you can also utilize the `npm pkg` subcommand:
36+
37+
```bash
38+
npm pkg set eslintConfig.extends=@hypetech/eslint-config
39+
```
40+
41+
Alternatively, you can also create a `.eslintrc.cjs` file in your project root and add the following content:
42+
43+
```js
44+
module.exports = {
45+
root: true,
46+
extends: '@hypetech/eslint-config',
47+
}
48+
```
49+
50+
> Notice: You should add configuration to your `package.json` if you are creating a library, and use a `.eslintrc.cjs` file if you are creating an application. And you should avoid both ways in the same project.
51+
52+
## Extending
53+
54+
To extend the configuration, you will have to create a `.eslintrc.js` file (or `.eslintrc.cjs` if your package is a `"type": "module"`) and import the HypeTech configuration using `require`:
55+
56+
```js
57+
module.exports = {
58+
...require('@hypetech/eslint-config'),
59+
rules: {
60+
'no-console': 'warn',
61+
},
62+
}
63+
```
64+
65+
# Contributing
66+
67+
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.
68+
69+
# License
70+
71+
This project is licensed under the terms of the [MIT license](/LICENSE).

index.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'plugin:react/recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:react-hooks/recommended',
7+
'prettier',
8+
'plugin:prettier/recommended',
9+
'plugin:@next/next/recommended',
10+
],
11+
plugins: ['@typescript-eslint', 'import', 'unused-imports'],
12+
parserOptions: {
13+
ecmaVersion: 2020,
14+
sourceType: 'module',
15+
ecmaFeatures: {
16+
jsx: true,
17+
},
18+
},
19+
rules: {
20+
'@typescript-eslint/no-empty-interface': 'error',
21+
'@typescript-eslint/explicit-module-boundary-types': 'off',
22+
'@typescript-eslint/no-unused-vars': 'off',
23+
'@typescript-eslint/no-var-requires': 'off',
24+
'@typescript-eslint/padding-line-between-statements': [
25+
'error',
26+
{
27+
blankLine: 'always',
28+
prev: ['const', 'let', 'var', 'export', 'interface', 'type'],
29+
next: '*',
30+
},
31+
{
32+
blankLine: 'any',
33+
prev: ['const', 'let', 'var'],
34+
next: ['const', 'let', 'var'],
35+
},
36+
{ blankLine: 'always', prev: '*', next: ['interface', 'type'] },
37+
],
38+
'import/order': [
39+
'error',
40+
{
41+
'newlines-between': 'always',
42+
// alphabetize: { order: 'asc', caseInsensitive: true },
43+
// Custom groups for sorting
44+
pathGroups: [
45+
'@/',
46+
'types',
47+
'config',
48+
'lib',
49+
'app',
50+
'components',
51+
'pages',
52+
'res',
53+
].map(function (path) {
54+
return {
55+
pattern: path + '/**',
56+
group: 'external',
57+
position: 'after',
58+
}
59+
}),
60+
pathGroupsExcludedImportTypes: ['builtin'],
61+
},
62+
],
63+
'padding-line-between-statements': 'off',
64+
'prettier/prettier': 'error',
65+
'react/react-in-jsx-scope': 'off',
66+
'unused-imports/no-unused-imports-ts': 'error',
67+
'unused-imports/no-unused-vars-ts': [
68+
'warn',
69+
{
70+
vars: 'all',
71+
varsIgnorePattern: '^_',
72+
args: 'after-used',
73+
argsIgnorePattern: '^_',
74+
},
75+
],
76+
},
77+
settings: {
78+
react: {
79+
version: 'detect',
80+
},
81+
},
82+
}

0 commit comments

Comments
 (0)