-
Notifications
You must be signed in to change notification settings - Fork 14
/
template.rb
75 lines (64 loc) · 2.37 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Javascript code linting and formatting
# ######################################
add_yarn_package_extension_dependency("eslint-plugin-prettier", "eslint-config-prettier")
add_yarn_package_extension_dependency("stylelint-scss", "known-css-properties")
yarn_add_dev_dependencies %w[
eslint
eslint-config-ackama
eslint-plugin-node
eslint-plugin-import
eslint-plugin-prettier
eslint-plugin-eslint-comments
prettier
prettier-config-ackama
prettier-plugin-packagejson
]
copy_file "variants/frontend-base/.eslintrc.js", ".eslintrc.js"
template "variants/frontend-base/.prettierignore.tt", ".prettierignore"
package_json.merge! do |pj|
{
"prettier" => "prettier-config-ackama",
"browserslist" => ["defaults"],
"scripts" => pj.fetch("scripts", {}).merge({
"js-lint" => "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts,tsx,jsx",
"js-lint-fix" => "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts,tsx,jsx --fix",
"format-check" => "prettier --check './**/*.{css,scss,json,md,js,ts,tsx,jsx}'",
"format-fix" => "prettier --write './**/*.{css,scss,json,md,js,ts,tsx,jsx}'",
"scss-lint" => "stylelint '**/*.{css,scss}'",
"scss-lint-fix" => "stylelint '**/*.{css,scss}' --fix"
})
}
end
append_to_file "bin/ci-run" do
<<~ESLINT
echo "* ******************************************************"
echo "* Running JS linting"
echo "* ******************************************************"
#{package_json.manager.native_run_command("js-lint").join(" ")}
ESLINT
end
append_to_file "bin/ci-run" do
<<~PRETTIER
echo "* ******************************************************"
echo "* Running JS linting"
echo "* ******************************************************"
#{package_json.manager.native_run_command("format-check").join(" ")}
PRETTIER
end
# SCSS Linting
yarn_add_dev_dependencies %w[
postcss
stylelint
stylelint-scss
stylelint-config-recommended-scss
]
copy_file "variants/frontend-base/.stylelintrc.js", ".stylelintrc.js"
template "variants/frontend-base/.stylelintignore.tt", ".stylelintignore"
append_to_file "bin/ci-run" do
<<~SASSLINT
echo "* ******************************************************"
echo "* Running SCSS linting"
echo "* ******************************************************"
#{package_json.manager.native_run_command("scss-lint").join(" ")}
SASSLINT
end