Skip to content

Commit bc011e3

Browse files
committed
Unify CS and add CI linter
1 parent 7071e59 commit bc011e3

Some content is hidden

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

94 files changed

+37338
-36895
lines changed

.eslintrc.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
],
17+
rules: {
18+
indent: ['error', 4, { SwitchCase: 1 }],
19+
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
20+
curly: ['error', 'all'],
21+
quotes: ['error', 'single', { avoidEscape: true }],
22+
'comma-dangle': ['error', {
23+
arrays: 'always-multiline',
24+
objects: 'always-multiline',
25+
functions: 'never',
26+
imports: 'always-multiline',
27+
exports: 'always-multiline',
28+
}],
29+
},
30+
reportUnusedDisableDirectives: true,
31+
};

.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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
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

1212

@@ -31,10 +31,10 @@ require('./tasks/collections/docs')(gulp);
3131
---------------*/
3232

3333
if (config.rtl) {
34-
require('./tasks/collections/rtl')(gulp);
34+
require('./tasks/collections/rtl')(gulp);
3535
}
3636

3737
/* Admin Tasks */
3838
if (config.admin) {
39-
require('./tasks/collections/admin')(gulp);
39+
require('./tasks/collections/admin')(gulp);
4040
}

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
},

scripts/nightly-version.js

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,75 @@ const repoUrlPath = 'fomantic/Fomantic-UI'
1717
const npmBase = 'https://registry.npmjs.org'
1818
const npmPackage = 'fomantic-ui'
1919
const currentRev = childProcess // get the current rev from the repo
20-
.execSync('git rev-parse HEAD')
21-
.toString()
22-
.trim()
23-
.slice(0, 7)
20+
.execSync('git rev-parse HEAD')
21+
.toString()
22+
.trim()
23+
.slice(0, 7)
2424

2525
const getNextVersion = async function () {
26-
const versions = await fetch(`${ghBase}/repos/${repoUrlPath}/milestones`)
27-
.then(r => r.json())
28-
.then(milestones => milestones.filter(m => m.title.indexOf('x') === -1)) // remove all versions with `x` in it
29-
.then(versions => versions.map(m => m.title)) // create array of versions
30-
.then(versions => semver.sort(versions))
26+
const versions = await fetch(`${ghBase}/repos/${repoUrlPath}/milestones`)
27+
.then(r => r.json())
28+
.then(milestones => milestones.filter(m => m.title.indexOf('x') === -1)) // remove all versions with `x` in it
29+
.then(versions => versions.map(m => m.title)) // create array of versions
30+
.then(versions => semver.sort(versions))
3131

32-
// Return first entry aka the smallest version in milestones which would therefore
33-
// be the next version
34-
return semver.parse(versions[0])
32+
// Return first entry aka the smallest version in milestones which would therefore
33+
// be the next version
34+
return semver.parse(versions[0])
3535
}
3636

3737
const getPublishedVersion = async function () {
38-
// get the latest published nightly tagged version
39-
return semver.parse(
40-
await fetch(`${npmBase}/${npmPackage}`)
41-
.then(r => r.json())
42-
.then(p => {
43-
let nightly = p['dist-tags'].nightly ?? '';
44-
let versionInfo = p.versions[nightly] ?? {};
45-
let buildCommit = nightly.indexOf('+')===-1 && versionInfo.gitHead ? '+'+(versionInfo.gitHead ?? '').slice(0,7) : '';
46-
return nightly+buildCommit;
47-
})
48-
)
38+
// get the latest published nightly tagged version
39+
return semver.parse(
40+
await fetch(`${npmBase}/${npmPackage}`)
41+
.then(r => r.json())
42+
.then(p => {
43+
let nightly = p['dist-tags'].nightly ?? '';
44+
let versionInfo = p.versions[nightly] ?? {};
45+
let buildCommit = nightly.indexOf('+')===-1 && versionInfo.gitHead ? '+'+(versionInfo.gitHead ?? '').slice(0,7) : '';
46+
return nightly+buildCommit;
47+
})
48+
)
4949
}
5050

5151
const getNightlyVersion = async function () {
52-
const next = semver.parse(await getNextVersion())
53-
const current = semver.parse(await getPublishedVersion())
52+
const next = semver.parse(await getNextVersion())
53+
const current = semver.parse(await getPublishedVersion())
5454

55-
if (current.build[0] === currentRev) {
56-
actions.setOutput('shouldPublish', false)
55+
if (current.build[0] === currentRev) {
56+
actions.setOutput('shouldPublish', false)
5757

58-
console.log('No new commits since last publish. Exiting.')
59-
process.exit(0)
60-
return
61-
}
58+
console.log('No new commits since last publish. Exiting.')
59+
process.exit(0)
60+
return
61+
}
6262

63-
let nightlyVersion = `${next.version}-beta.0`
63+
let nightlyVersion = `${next.version}-beta.0`
6464

65-
// Check if published version is the same version as next version.
66-
// Only check major, minor and patch as previously published nightly
67-
// versions would include prerelease tag and build metadata
68-
if (semver.eq(`${next.major}.${next.minor}.${next.patch}`, `${current.major}.${current.minor}.${current.patch}`)) {
65+
// Check if published version is the same version as next version.
66+
// Only check major, minor and patch as previously published nightly
67+
// versions would include prerelease tag and build metadata
68+
if (semver.eq(`${next.major}.${next.minor}.${next.patch}`, `${current.major}.${current.minor}.${current.patch}`)) {
6969
// If they match then a nightly version has already been published, so we need to increment
7070
// the prerelease and add the new rev as build metadata
71-
nightlyVersion = semver.inc(
72-
`${next.version}-beta.${current.prerelease[1]}`,
73-
'prerelease'
74-
)
75-
}
71+
nightlyVersion = semver.inc(
72+
`${next.version}-beta.${current.prerelease[1]}`,
73+
'prerelease'
74+
)
75+
}
7676

77-
actions.setOutput('shouldPublish', 'yes')
78-
return `${nightlyVersion}+${currentRev}`
77+
actions.setOutput('shouldPublish', 'yes')
78+
return `${nightlyVersion}+${currentRev}`
7979
}
8080

8181
getNightlyVersion()
82-
.then(nightlyVersion => {
83-
pkg.version = nightlyVersion
84-
})
85-
.then(() => {
86-
fs.writeFileSync(
87-
path.resolve(__dirname, '../package.json'),
88-
JSON.stringify(pkg, null, 2)
89-
)
90-
})
91-
.then(() => console.log(`Done (${pkg.version})`))
82+
.then(nightlyVersion => {
83+
pkg.version = nightlyVersion
84+
})
85+
.then(() => {
86+
fs.writeFileSync(
87+
path.resolve(__dirname, '../package.json'),
88+
JSON.stringify(pkg, null, 2)
89+
)
90+
})
91+
.then(() => console.log(`Done (${pkg.version})`))

0 commit comments

Comments
 (0)