Skip to content

Commit 8a8d841

Browse files
authored
feat(chore): add lint using CI
Unified CS improves readability, prevents hidden mistakes and enforce unified contribution standards. And in a long term, it also simplifies merge conflicts. The CS rules are based on industry standard eslint-config-airbnb-base, but all rules might be too hard to fix at once. This PR focuses on whitespace CS which can be autofixed /wo having to review each line manually.
1 parent 3767ba8 commit 8a8d841

Some content is hidden

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

89 files changed

+33551
-33593
lines changed

.eslintrc.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
},
6+
extends: [
7+
],
8+
parserOptions: {
9+
ecmaVersion: '2020',
10+
sourceType: 'module',
11+
},
12+
ignorePatterns: [
13+
'/dist',
14+
'/examples/assets/library',
15+
'/test/coverage',
16+
'/test/helpers',
17+
],
18+
rules: {
19+
indent: ['error', 4, { SwitchCase: 1 }],
20+
'keyword-spacing': ['error'],
21+
'space-in-parens': ['error'],
22+
'comma-spacing': ['error'],
23+
'comma-style': ['error', 'last', {
24+
// https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/style.js#L54
25+
exceptions: {
26+
ArrayExpression: false,
27+
ArrayPattern: false,
28+
ArrowFunctionExpression: false,
29+
CallExpression: false,
30+
FunctionDeclaration: false,
31+
FunctionExpression: false,
32+
ImportDeclaration: false,
33+
ObjectExpression: false,
34+
ObjectPattern: false,
35+
VariableDeclaration: false,
36+
NewExpression: false,
37+
},
38+
}],
39+
'space-before-function-paren': ['error', {
40+
named: 'never',
41+
anonymous: 'always',
42+
asyncArrow: 'always',
43+
}],
44+
'space-infix-ops': ['error'],
45+
'array-bracket-spacing': ['error', 'never'],
46+
'object-curly-spacing': ['error', 'always'],
47+
'computed-property-spacing': ['error', 'never'],
48+
'space-before-blocks': ['error'],
49+
'one-var-declaration-per-line': ['error', 'always'],
50+
'function-paren-newline': ['error', 'multiline-arguments'],
51+
'padding-line-between-statements': ['error', {
52+
blankLine: 'always',
53+
prev: '*',
54+
next: ['continue', 'break', 'export', 'return', 'throw'],
55+
}],
56+
'spaced-comment': ['error', 'always', {
57+
line: {
58+
markers: ['/'],
59+
exceptions: ['-', '+'],
60+
},
61+
block: {
62+
markers: ['!'],
63+
exceptions: ['*'],
64+
balanced: true,
65+
},
66+
}],
67+
'padded-blocks': ['error', 'never'],
68+
'no-multiple-empty-lines': ['error', {
69+
max: 1,
70+
maxBOF: 0,
71+
maxEOF: 0,
72+
}],
73+
'no-multi-spaces': ['error', {
74+
exceptions: {
75+
Property: true,
76+
VariableDeclarator: true,
77+
},
78+
}],
79+
'brace-style': ['error'],
80+
curly: ['error'],
81+
'object-shorthand': ['error', 'never'],
82+
'object-curly-newline': ['error', {
83+
// https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/style.js#L395
84+
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
85+
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
86+
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
87+
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
88+
}],
89+
'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
90+
'dot-notation': ['error', { allowKeywords: true }],
91+
'arrow-parens': ['error'],
92+
quotes: ['error', 'single', { avoidEscape: true }],
93+
'quote-props': ['error', 'as-needed', {
94+
keywords: false,
95+
numbers: false,
96+
}],
97+
'comma-dangle': ['error', {
98+
arrays: 'always-multiline',
99+
objects: 'always-multiline',
100+
functions: 'never',
101+
imports: 'always-multiline',
102+
exports: 'always-multiline',
103+
}],
104+
semi: ['error'],
105+
'no-extra-semi': ['error'],
106+
'no-trailing-spaces': ['error'],
107+
},
108+
reportUnusedDisableDirectives: true,
109+
};

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
name: CI
2-
on: [pull_request]
2+
on: [push, pull_request]
33
permissions:
44
contents: read
55

66
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
- name: Install dependencies
14+
run: yarn
15+
- name: Lint JS files
16+
run: npm run lint
717
test:
818
name: Test build process on node ${{ matrix.node-version }}
919
runs-on: ubuntu-latest
@@ -13,13 +23,13 @@ jobs:
1323
node-version: [12, 14, 16, 18]
1424
steps:
1525
- uses: actions/checkout@v3
16-
- name: Use Node.js ${{ matrix.node-version }}
26+
- name: Setup Node.js ${{ matrix.node-version }}
1727
uses: actions/setup-node@v3
1828
with:
1929
node-version: ${{ matrix.node-version }}
2030
- name: pre-install
2131
run: sh ./scripts/preinstall.sh
22-
- name: install dependencies
32+
- name: Install dependencies
2333
run: yarn
2434
- name: pre fomantic install & gulp build
2535
run: yarn gulp install

examples/assets/show-examples.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
$(document)
2-
.ready(function() {
3-
// add popup to show name
4-
$('.ui:not(.container, .grid)').each(function() {
5-
$(this)
6-
.popup({
7-
on : 'hover',
8-
variation : 'small inverted',
9-
exclusive : true,
10-
content : $(this).attr('class')
11-
})
12-
;
13-
});
14-
})
2+
.ready(function () {
3+
// add popup to show name
4+
$('.ui:not(.container, .grid)').each(function () {
5+
$(this)
6+
.popup({
7+
on: 'hover',
8+
variation: 'small inverted',
9+
exclusive: true,
10+
content: $(this).attr('class'),
11+
})
12+
;
13+
});
14+
})
1515
;

gulpfile.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
*******************************/
44

55
var
6-
gulp = require('gulp'),
6+
gulp = require('gulp'),
77

8-
// read user config to know what task to load
9-
config = require('./tasks/config/user')
8+
// read user config to know what task to load
9+
config = require('./tasks/config/user')
1010
;
1111

12-
1312
/*******************************
1413
* Tasks
1514
*******************************/
@@ -20,21 +19,21 @@ require('./tasks/collections/install')(gulp);
2019

2120
gulp.task('default', gulp.series('check-install'));
2221

23-
/*--------------
22+
/* --------------
2423
Docs
25-
---------------*/
24+
--------------- */
2625

2726
require('./tasks/collections/docs')(gulp);
2827

29-
/*--------------
28+
/* --------------
3029
RTL
31-
---------------*/
30+
--------------- */
3231

3332
if (config.rtl) {
34-
require('./tasks/collections/rtl')(gulp);
33+
require('./tasks/collections/rtl')(gulp);
3534
}
3635

3736
/* Admin Tasks */
3837
if (config.admin) {
39-
require('./tasks/collections/admin')(gulp);
38+
require('./tasks/collections/admin')(gulp);
4039
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
},
2626
"scripts": {
2727
"build": "gulp build",
28-
"changelog": "auto-changelog -p"
28+
"changelog": "auto-changelog -p",
29+
"lint": "eslint -c .eslintrc.js --ext .js .",
30+
"lint-fix": "eslint -c .eslintrc.js --ext .js . --fix"
2931
},
3032
"dependencies": {
3133
"@actions/core": "^1.6.0",
@@ -73,6 +75,7 @@
7375
"devDependencies": {
7476
"all-contributors-cli": "^6.7.0",
7577
"auto-changelog": "^2.4.0",
78+
"eslint": "^8.28.0",
7679
"node-fetch": "^2.6.0",
7780
"semver": "^7.3.5"
7881
},

0 commit comments

Comments
 (0)