Skip to content

Commit 2dedd1b

Browse files
committed
Update yarn
Add Prettier Improve eslint config Add lint-staged and Husky Add formatter settings + extension recommendation Editorconfig clarification
1 parent 4708648 commit 2dedd1b

22 files changed

+4984
-2677
lines changed

.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/workflows/lint.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,28 @@ jobs:
1919
with:
2020
severity: error
2121

22+
prettier:
23+
name: Prettier
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v3
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v3
31+
with:
32+
cache: yarn
33+
cache-dependency-path: yarn.lock
34+
35+
- name: Install Node packages
36+
run: yarn install --frozen-lockfile
37+
38+
- name: Run Prettier
39+
run: yarn prettier --check .
40+
2241
eslint:
2342
name: ESLint
2443
runs-on: ubuntu-latest
25-
defaults:
26-
run:
27-
working-directory: web
2844
steps:
2945
- name: Checkout code
3046
uses: actions/checkout@v3
@@ -33,20 +49,17 @@ jobs:
3349
uses: actions/setup-node@v3
3450
with:
3551
cache: yarn
36-
cache-dependency-path: web/yarn.lock
52+
cache-dependency-path: yarn.lock
3753

3854
- name: Install Node packages
3955
run: yarn install --frozen-lockfile
4056

4157
- name: Run ESLint
42-
run: yarn eslint js
58+
run: yarn eslint web/js/
4359

4460
stylelint:
4561
name: Stylelint
4662
runs-on: ubuntu-latest
47-
defaults:
48-
run:
49-
working-directory: web
5063
steps:
5164
- name: Checkout code
5265
uses: actions/checkout@v3
@@ -55,10 +68,10 @@ jobs:
5568
uses: actions/setup-node@v3
5669
with:
5770
cache: yarn
58-
cache-dependency-path: web/yarn.lock
71+
cache-dependency-path: yarn.lock
5972

6073
- name: Install Node packages
6174
run: yarn install --frozen-lockfile
6275

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

.gitignore

Lines changed: 21 additions & 4 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/
1422
test/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

.lintstagedrc.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
// Run Stylelint on CSS files
3+
'*.css': 'stylelint --fix',
4+
// Run ESLint on TS, TSX, JS, JSX files
5+
'*.{ts,js}?(x)': 'eslint --fix',
6+
// Run Prettier everywhere
7+
'*': 'prettier --write --ignore-unknown'
8+
};

.prettierignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
3+
# Minified files
4+
*.min.css
5+
*.min.js
6+
7+
# Nginx files (for now)
8+
**/nginx/
9+
10+
# Web templates (for now)
11+
web/templates/
12+
13+
# Vendor/packages
14+
.pnp.*
15+
.yarn/*
16+
vendor/
17+
composer.phar
18+
composer.json
19+
composer.lock
20+
21+
# Logs
22+
logs
23+
*.log
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
pnpm-debug.log*
28+
lerna-debug.log*
29+
30+
# PNPM, NPM and YARN
31+
pnpm-lock.yaml
32+
package-lock.json
33+
yarn.lock

.prettierrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
phpVersion: "8.1",
3+
braceStyle: "1tbs",
4+
};

.stylelintrc.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
3+
rules: {
4+
'selector-class-pattern': null,
5+
'no-descending-specificity': null,
6+
'block-no-empty': null,
7+
8+
'max-line-length': null,
9+
'declaration-block-no-shorthand-property-overrides': null,
10+
'selector-id-pattern': null
11+
}
12+
}

0 commit comments

Comments
 (0)