Skip to content

Commit 6bb7a59

Browse files
committed
add github action to lint js/less/html
1 parent 1744716 commit 6bb7a59

5 files changed

Lines changed: 158 additions & 0 deletions

File tree

‎.eslintrc.js‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
},
6+
extends: [
7+
'airbnb-base',
8+
'plugin:unicorn/recommended',
9+
],
10+
parserOptions: {
11+
ecmaVersion: '2022',
12+
sourceType: 'module',
13+
},
14+
ignorePatterns: [
15+
'!.*',
16+
'*.min.js',
17+
],
18+
rules: {
19+
'brace-style': ['error', '1tbs'],
20+
'comma-dangle': ['error', {
21+
arrays: 'always-multiline',
22+
exports: 'always-multiline',
23+
functions: 'never',
24+
imports: 'always-multiline',
25+
objects: 'always-multiline',
26+
}],
27+
curly: ['error', 'all'],
28+
indent: ['error', 4, {
29+
SwitchCase: 1,
30+
}],
31+
'linebreak-style': ['error', 'unix'],
32+
'no-multi-spaces': ['error', {
33+
exceptions: {
34+
Property: true,
35+
VariableDeclarator: true,
36+
},
37+
}],
38+
'object-shorthand': ['error', 'never'],
39+
'padding-line-between-statements': ['error', {
40+
blankLine: 'always',
41+
next: ['continue', 'break', 'export', 'return', 'throw'],
42+
prev: '*',
43+
}],
44+
'spaced-comment': ['error', 'always', {
45+
block: {
46+
balanced: true,
47+
exceptions: ['*'],
48+
markers: ['!'],
49+
},
50+
line: {
51+
exceptions: ['-', '+'],
52+
markers: ['/'],
53+
},
54+
}],
55+
strict: 'off',
56+
'wrap-iife': ['error', 'inside'],
57+
'func-names': 'off',
58+
'no-param-reassign': 'off',
59+
'no-use-before-define': 'off',
60+
'prefer-destructuring': 'off',
61+
'unicorn/prefer-module': 'off',
62+
'unicorn/prefer-query-selector': 'off',
63+
'unicorn/no-array-for-each': 'off',
64+
'unicorn/prevent-abbreviations': 'off',
65+
},
66+
reportUnusedDisableDirectives: true,
67+
globals: {
68+
bootstrap: true,
69+
},
70+
};

‎.github/workflows/validate.yml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Validate
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
validate:
12+
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)"
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v6
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v7
21+
with:
22+
node-version: 22
23+
24+
- name: Install Node dependencies
25+
run: npm install --omit=optional
26+
27+
- name: Lint JavaScript
28+
run: npx eslint --ext .js .
29+
30+
- name: Lint Less
31+
run: npx stylelint "./styles/styles.less"
32+
33+
- name: Setup Ruby
34+
uses: ruby/setup-ruby@v1
35+
with:
36+
ruby-version: "3.4"
37+
bundler-cache: true
38+
39+
- name: Build site
40+
run: bundle exec jekyll build
41+
42+
- name: Lint HTML
43+
# Find generated HTML, excluding news pages as then contain HTML4
44+
run: find _site -name '*.html' ! -path '_site/news/*/*.html' -print0 | xargs -0 -r npx htmlhint -c .htmlhintrc.js
45+

‎.htmlhintrc‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"doctype-first": true,
3+
"doctype-html5": true,
4+
5+
"tagname-lowercase": true,
6+
"attr-lowercase": true,
7+
"attr-value-double-quotes": true,
8+
"attr-no-duplication": true,
9+
"attr-value-no-duplication": true,
10+
11+
"tag-pair": true,
12+
"empty-tag-not-self-closed": true,
13+
"tag-no-obsolete": true,
14+
15+
"spec-char-escape": true,
16+
"src-not-empty": true,
17+
"alt-require": true,
18+
"id-unique": true,
19+
20+
"html-lang-require": true,
21+
"title-require": true,
22+
23+
"button-type-require": true,
24+
"input-requires-label": true,
25+
"frame-title-require": true,
26+
}

‎package.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,14 @@
33
"less": "^4.4.0",
44
"less-plugin-clean-css": "^1.6.0",
55
"uglify-js": "^3.19.3"
6+
},
7+
"devDependencies": {
8+
"stylelint": "^17.16.0",
9+
"stylelint-config-standard-less": "^4.1.0",
10+
"eslint": "^8.57.0",
11+
"eslint-config-airbnb-base": "^15.0.0",
12+
"eslint-plugin-import": "^2.29.1",
13+
"eslint-plugin-unicorn": "^54.0.0",
14+
"htmlhint": "^1.1.4"
615
}
716
}

‎stylelint.config.mjs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('stylelint').Config} */
2+
export default {
3+
extends: ["stylelint-config-standard-less"],
4+
5+
rules: {
6+
"no-descending-specificity": null
7+
}
8+
};

0 commit comments

Comments
 (0)