Skip to content

Commit 44314eb

Browse files
authored
Merge pull request hestiacp#3080 from hestiacp/feature/improve-eslint
Improve ESLint, add Prettier and pre-commit hooks
2 parents 39ff3f1 + 2ecb74f commit 44314eb

File tree

979 files changed

+55464
-48911
lines changed

Some content is hidden

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

979 files changed

+55464
-48911
lines changed

.drone.yml

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ platform:
1919
arch: amd64
2020

2121
steps:
22-
- name: Download submodules
23-
image: alpine/git
24-
commands:
25-
- git submodule update --init --recursive
26-
- name: Build Hestia package and install
27-
commands:
28-
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
29-
- name: Run system / user tests
30-
commands:
31-
- bats ./test/test.bats
32-
- name: Run restore tests
33-
commands:
34-
- bats ./test/restore.bats
35-
- name: Run config tests
36-
commands:
37-
- bats ./test/config-tests.bats
22+
- name: Download submodules
23+
image: alpine/git
24+
commands:
25+
- git submodule update --init --recursive
26+
- name: Build Hestia package and install
27+
commands:
28+
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
29+
- name: Run system / user tests
30+
commands:
31+
- bats ./test/test.bats
32+
- name: Run restore tests
33+
commands:
34+
- bats ./test/restore.bats
35+
- name: Run config tests
36+
commands:
37+
- bats ./test/config-tests.bats
3838

3939
trigger:
40-
event: [ pull_request, push ]
40+
event: [pull_request, push]
4141
ref:
42-
- refs/heads/staging/*
43-
- refs/heads/beta
44-
- refs/heads/release
45-
- refs/heads/main
46-
- refs/pull/*/head
42+
- refs/heads/staging/*
43+
- refs/heads/beta
44+
- refs/heads/release
45+
- refs/heads/main
46+
- refs/pull/*/head
4747

4848
---
4949
kind: pipeline
@@ -66,35 +66,35 @@ platform:
6666
arch: amd64
6767

6868
steps:
69-
- name: Download submodules
70-
image: alpine/git
71-
commands:
72-
- git submodule update --init --recursive
73-
- name: Build Hestia package install
74-
commands:
75-
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
76-
- name: Run system / user tests
77-
commands:
78-
- bats ./test/test.bats
79-
- name: Run restore tests
80-
commands:
81-
- bats ./test/restore.bats
82-
- name: Run Letsencrypt test against Staging
83-
commands:
84-
- cp /root/le-env.sh /tmp/hestia-le-env.sh
85-
- bats ./test/letsencrypt.bats
86-
- name: Run config tests
87-
commands:
88-
- bats ./test/config-tests.bats
69+
- name: Download submodules
70+
image: alpine/git
71+
commands:
72+
- git submodule update --init --recursive
73+
- name: Build Hestia package install
74+
commands:
75+
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
76+
- name: Run system / user tests
77+
commands:
78+
- bats ./test/test.bats
79+
- name: Run restore tests
80+
commands:
81+
- bats ./test/restore.bats
82+
- name: Run Letsencrypt test against Staging
83+
commands:
84+
- cp /root/le-env.sh /tmp/hestia-le-env.sh
85+
- bats ./test/letsencrypt.bats
86+
- name: Run config tests
87+
commands:
88+
- bats ./test/config-tests.bats
8989

9090
trigger:
91-
event: [ pull_request, push ]
91+
event: [pull_request, push]
9292
ref:
93-
- refs/heads/staging/*
94-
- refs/heads/beta
95-
- refs/heads/release
96-
- refs/heads/main
97-
- refs/pull/*/head
93+
- refs/heads/staging/*
94+
- refs/heads/beta
95+
- refs/heads/release
96+
- refs/heads/main
97+
- refs/pull/*/head
9898

9999
---
100100
kind: pipeline
@@ -109,10 +109,10 @@ steps:
109109
- name: Build
110110
image: debian:bullseye
111111
commands:
112-
- ln -snf /etc/localtime && echo CET > /etc/timezone
113-
- ./src/hst_autocompile.sh --dontinstalldeps --hestia --debug --cross --noinstall --keepbuild --debug '~localsrc'
114-
- mkdir -p ./hestia/
115-
- mv /tmp/hestiacp-src/deb/*.deb ./hestia/
112+
- ln -snf /etc/localtime && echo CET > /etc/timezone
113+
- ./src/hst_autocompile.sh --dontinstalldeps --hestia --debug --cross --noinstall --keepbuild --debug '~localsrc'
114+
- mkdir -p ./hestia/
115+
- mv /tmp/hestiacp-src/deb/*.deb ./hestia/
116116
- name: Upload
117117
image: appleboy/drone-scp
118118
settings:
@@ -128,4 +128,4 @@ steps:
128128
- ./hestia/*
129129

130130
trigger:
131-
event: [ promote]
131+
event: [promote]

.editorconfig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# editorconfig.org
2-
32
root = true
43

54
[*]
65
charset = utf-8
6+
indent_style = tab
7+
end_of_line = lf
78
insert_final_newline = true
89
trim_trailing_whitespace = true
10+
max_line_length = 100
11+
12+
# Markdown syntax specifies that trailing whitespaces can be meaningful,
13+
# so let’s not trim those. e.g. 2 trailing spaces = linebreak (<br />)
14+
# See https://daringfireball.net/projects/markdown/syntax#p
15+
[*.md]
16+
trim_trailing_whitespace = false
917

10-
[*.{html,css}]
18+
# YAML forbids using tabs.
19+
# See https://yaml.org/faq.html
20+
[*.{yml,yaml}]
1121
indent_size = 2
1222
indent_style = space

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pnp.*
2+
.yarn/*
3+
web/js/vendor/

.eslintrc.cjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 'latest',
5+
},
6+
extends: ['eslint:recommended', 'plugin:editorconfig/noconflict', 'prettier'],
7+
plugins: ['editorconfig'],
8+
ignorePatterns: ['*.cjs'],
9+
env: {
10+
browser: true,
11+
es2021: true,
12+
},
13+
globals: {
14+
$: 'readonly',
15+
jQuery: 'readonly',
16+
App: 'readonly',
17+
},
18+
rules: {
19+
'no-unused-vars': 'off',
20+
'no-undef': 'off',
21+
'no-redeclare': 'off',
22+
},
23+
};

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
3-
- name: Support Question
4-
url: https://forum.hestiacp.com
5-
about: We use GitHub issues only to discuss about HestiaCP bugs and new features.
3+
- name: Support Question
4+
url: https://forum.hestiacp.com
5+
about: We use GitHub issues only to discuss about HestiaCP bugs and new features.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
########################################################################################
2+
# "yarn install" composite action for yarn 2/3/4+ and "nodeLinker: node-modules" #
3+
#--------------------------------------------------------------------------------------#
4+
# Cache: #
5+
# - Downloaded zip archive (multi-arch, preserved across yarn.lock changes) #
6+
# - Yarn install state (discarded on yarn.lock changes) #
7+
# References: #
8+
# - bench: https://gist.github.com/belgattitude/0ecd26155b47e7be1be6163ecfbb0f0b #
9+
# - vs @setup/node: https://github.com/actions/setup-node/issues/325 #
10+
########################################################################################
11+
12+
name: "Yarn install"
13+
description: "Run yarn install with node_modules linker and cache enabled"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Expose yarn config as "$GITHUB_OUTPUT"
19+
id: yarn-config
20+
shell: bash
21+
run: |
22+
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
23+
24+
# Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325
25+
# Yarn cache is also reusable between arch and os.
26+
- name: Restore yarn cache
27+
uses: actions/cache@v3
28+
id: yarn-download-cache
29+
with:
30+
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
31+
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
32+
restore-keys: |
33+
yarn-download-cache-
34+
35+
# Invalidated on yarn.lock changes
36+
- name: Restore yarn install state
37+
id: yarn-install-state-cache
38+
uses: actions/cache@v3
39+
with:
40+
path: .yarn/ci-cache/
41+
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
42+
43+
- name: Install dependencies
44+
shell: bash
45+
run: |
46+
yarn install --immutable --inline-builds
47+
env:
48+
# CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action.
49+
YARN_ENABLE_GLOBAL_CACHE: "false" # Use local cache folder to keep downloaded archives
50+
YARN_NM_MODE: "hardlinks-local" # Hardlinks-(local|global) reduces io / node_modules size
51+
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change
52+
# Other environment variables
53+
HUSKY: "0" # By default do not run HUSKY install

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: 2
22
updates:
3-
43
# Maintain dependencies for GitHub Actions
54
- package-ecosystem: "github-actions"
65
directory: "/"

.github/workflows/lint.yml

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,73 @@ jobs:
1111
name: ShellCheck
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v3
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Run ShellCheck
18+
uses: ludeeus/action-shellcheck@6d3f514f44620b9d4488e380339edc0d9bbe2fba
19+
with:
20+
severity: error
21+
22+
prettier:
23+
name: Prettier
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v3
1628

17-
- name: Run ShellCheck
18-
uses: ludeeus/action-shellcheck@6d3f514f44620b9d4488e380339edc0d9bbe2fba
19-
with:
20-
severity: error
29+
- name: Setup Node
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: 16
33+
34+
- name: Install yarn v3
35+
run: corepack enable && corepack prepare yarn@stable --activate
36+
37+
- name: Install Node packages
38+
uses: ./.github/actions/yarn-nm-install
39+
40+
- name: Run Prettier
41+
run: yarn prettier --check .
2142

2243
eslint:
2344
name: ESLint
2445
runs-on: ubuntu-latest
25-
defaults:
26-
run:
27-
working-directory: web
2846
steps:
2947
- name: Checkout code
3048
uses: actions/checkout@v3
3149

3250
- name: Setup Node
3351
uses: actions/setup-node@v3
3452
with:
35-
cache: yarn
36-
cache-dependency-path: web/yarn.lock
53+
node-version: 16
54+
55+
- name: Install yarn v3
56+
run: corepack enable && corepack prepare yarn@stable --activate
3757

3858
- name: Install Node packages
39-
run: yarn install --frozen-lockfile
59+
uses: ./.github/actions/yarn-nm-install
4060

4161
- name: Run ESLint
42-
run: yarn eslint js
62+
run: yarn eslint web/js/
4363

4464
stylelint:
4565
name: Stylelint
4666
runs-on: ubuntu-latest
47-
defaults:
48-
run:
49-
working-directory: web
5067
steps:
5168
- name: Checkout code
5269
uses: actions/checkout@v3
5370

5471
- name: Setup Node
5572
uses: actions/setup-node@v3
5673
with:
57-
cache: yarn
58-
cache-dependency-path: web/yarn.lock
74+
node-version: 16
75+
76+
- name: Install yarn v3
77+
run: corepack enable && corepack prepare yarn@stable --activate
5978

6079
- name: Install Node packages
61-
run: yarn install --frozen-lockfile
80+
uses: ./.github/actions/yarn-nm-install
6281

6382
- name: Run Stylelint
64-
run: yarn stylelint css/src/themes/*.css
83+
run: yarn stylelint web/css/src/themes/*.css

.gitignore

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,32 @@
55
*.bz2
66
*.deb
77

8-
.vscode
8+
.vs
9+
.nova
10+
/.idea/
11+
.vscode/*
12+
!.vscode/settings.json
13+
!.vscode/tasks.json
14+
!.vscode/launch.json
15+
!.vscode/extensions.json
16+
!.vscode/*.code-snippets
917
.DS_Store
1018

1119
.env
1220
composer.phar
1321
test/vendor/
14-
test/node_modules/
22+
**/node_modules/
23+
web/src/vendor/filp
24+
web/src/vendor/psr
25+
web/src/vendor/composer/installed.json
1526
npm-debug.log
1627
.phpunit.result.cache
17-
.vs
18-
.nova
19-
/.idea/
28+
29+
# Yarn (not zero-installs)
30+
.pnp.*
31+
.yarn/*
32+
!.yarn/patches
33+
!.yarn/plugins
34+
!.yarn/releases
35+
!.yarn/sdks
36+
!.yarn/versions

.husky/pre-commit

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

0 commit comments

Comments
 (0)