Skip to content

Commit e9b5643

Browse files
committed
Comply to the new rules
1 parent ad8ae6a commit e9b5643

35 files changed

+614
-582
lines changed

build/build-plugins.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const bsPlugins = {
3939
}
4040
const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/'
4141

42-
const build = async (plugin) => {
42+
const build = async plugin => {
4343
console.log(`Building ${plugin} plugin...`)
4444

4545
const external = ['jquery', 'popper.js']
@@ -81,7 +81,7 @@ const build = async (plugin) => {
8181

8282
const main = async () => {
8383
try {
84-
await Promise.all(Object.keys(bsPlugins).map((plugin) => build(plugin)))
84+
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
8585
} catch (error) {
8686
console.error(error)
8787

build/change-version.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
3030
if (excludedDirectories.has(path.parse(directory).base)) {
3131
return
3232
}
33+
3334
fs.readdir(directory, (err, names) => {
3435
if (err) {
3536
errback(err)
3637
return
3738
}
38-
names.forEach((name) => {
39+
40+
names.forEach(name => {
3941
const filepath = path.join(directory, name)
4042
fs.lstat(filepath, (err, stats) => {
4143
if (err) {
4244
process.nextTick(errback, err)
4345
return
4446
}
47+
4548
if (stats.isDirectory()) {
4649
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
4750
} else if (stats.isFile()) {
@@ -55,18 +58,19 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
5558
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
5659
original = new RegExp(regExpQuote(original), 'g')
5760
replacement = regExpQuoteReplacement(replacement)
58-
const updateFile = DRY_RUN ? (filepath) => {
61+
const updateFile = DRY_RUN ? filepath => {
5962
if (allowedExtensions.has(path.parse(filepath).ext)) {
6063
console.log(`FILE: ${filepath}`)
6164
} else {
6265
console.log(`EXCLUDED:${filepath}`)
6366
}
64-
} : (filepath) => {
67+
} : filepath => {
6568
if (allowedExtensions.has(path.parse(filepath).ext)) {
6669
sh.sed('-i', original, replacement, filepath)
6770
}
6871
}
69-
walkAsync(directory, excludedDirectories, updateFile, (err) => {
72+
73+
walkAsync(directory, excludedDirectories, updateFile, err => {
7074
console.error('ERROR while traversing directory!:')
7175
console.error(err)
7276
process.exit(1)
@@ -79,6 +83,7 @@ function main(args) {
7983
console.error('Got arguments:', args)
8084
process.exit(1)
8185
}
86+
8287
const oldVersion = args[0]
8388
const newVersion = args[1]
8489
const EXCLUDED_DIRS = new Set([

build/generate-sri.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const files = [
4949
}
5050
]
5151

52-
files.forEach((file) => {
52+
files.forEach(file => {
5353
fs.readFile(file.file, 'utf8', (err, data) => {
5454
if (err) {
5555
throw err

build/postcss.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
module.exports = (ctx) => ({
3+
module.exports = ctx => ({
44
map: ctx.file.dirname.includes('examples') ? false : {
55
inline: false,
66
annotation: true,

build/zip-examples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sh.cp('-f', [
4343
sh.rm(`${folderName}/index.html`)
4444

4545
// get all examples' HTML files
46-
sh.find(`${folderName}/**/*.html`).forEach((file) => {
46+
sh.find(`${folderName}/**/*.html`).forEach(file => {
4747
const fileContents = sh.cat(file)
4848
.toString()
4949
.replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')

js/src/alert.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ import Util from './util'
1414
* ------------------------------------------------------------------------
1515
*/
1616

17-
const NAME = 'alert'
18-
const VERSION = '4.5.0'
19-
const DATA_KEY = 'bs.alert'
20-
const EVENT_KEY = `.${DATA_KEY}`
21-
const DATA_API_KEY = '.data-api'
22-
const JQUERY_NO_CONFLICT = $.fn[NAME]
17+
const NAME = 'alert'
18+
const VERSION = '4.5.0'
19+
const DATA_KEY = 'bs.alert'
20+
const EVENT_KEY = `.${DATA_KEY}`
21+
const DATA_API_KEY = '.data-api'
22+
const JQUERY_NO_CONFLICT = $.fn[NAME]
2323

2424
const SELECTOR_DISMISS = '[data-dismiss="alert"]'
2525

26-
const EVENT_CLOSE = `close${EVENT_KEY}`
27-
const EVENT_CLOSED = `closed${EVENT_KEY}`
26+
const EVENT_CLOSE = `close${EVENT_KEY}`
27+
const EVENT_CLOSED = `closed${EVENT_KEY}`
2828
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
2929

3030
const CLASS_NAME_ALERT = 'alert'
31-
const CLASS_NAME_FADE = 'fade'
32-
const CLASS_NAME_SHOW = 'show'
31+
const CLASS_NAME_FADE = 'fade'
32+
const CLASS_NAME_SHOW = 'show'
3333

3434
/**
3535
* ------------------------------------------------------------------------
@@ -74,7 +74,7 @@ class Alert {
7474

7575
_getRootElement(element) {
7676
const selector = Util.getSelectorFromElement(element)
77-
let parent = false
77+
let parent = false
7878

7979
if (selector) {
8080
parent = document.querySelector(selector)
@@ -105,7 +105,7 @@ class Alert {
105105
const transitionDuration = Util.getTransitionDurationFromElement(element)
106106

107107
$(element)
108-
.one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))
108+
.one(Util.TRANSITION_END, event => this._destroyElement(element, event))
109109
.emulateTransitionEnd(transitionDuration)
110110
}
111111

@@ -121,7 +121,7 @@ class Alert {
121121
static _jQueryInterface(config) {
122122
return this.each(function () {
123123
const $element = $(this)
124-
let data = $element.data(DATA_KEY)
124+
let data = $element.data(DATA_KEY)
125125

126126
if (!data) {
127127
data = new Alert(this)
@@ -163,9 +163,9 @@ $(document).on(
163163
* ------------------------------------------------------------------------
164164
*/
165165

166-
$.fn[NAME] = Alert._jQueryInterface
166+
$.fn[NAME] = Alert._jQueryInterface
167167
$.fn[NAME].Constructor = Alert
168-
$.fn[NAME].noConflict = () => {
168+
$.fn[NAME].noConflict = () => {
169169
$.fn[NAME] = JQUERY_NO_CONFLICT
170170
return Alert._jQueryInterface
171171
}

js/src/button.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ import $ from 'jquery'
1313
* ------------------------------------------------------------------------
1414
*/
1515

16-
const NAME = 'button'
17-
const VERSION = '4.5.0'
18-
const DATA_KEY = 'bs.button'
19-
const EVENT_KEY = `.${DATA_KEY}`
20-
const DATA_API_KEY = '.data-api'
21-
const JQUERY_NO_CONFLICT = $.fn[NAME]
16+
const NAME = 'button'
17+
const VERSION = '4.5.0'
18+
const DATA_KEY = 'bs.button'
19+
const EVENT_KEY = `.${DATA_KEY}`
20+
const DATA_API_KEY = '.data-api'
21+
const JQUERY_NO_CONFLICT = $.fn[NAME]
2222

2323
const CLASS_NAME_ACTIVE = 'active'
2424
const CLASS_NAME_BUTTON = 'btn'
25-
const CLASS_NAME_FOCUS = 'focus'
25+
const CLASS_NAME_FOCUS = 'focus'
2626

27-
const SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'
28-
const SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'
29-
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'
27+
const SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'
28+
const SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'
29+
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'
3030
const SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn'
31-
const SELECTOR_INPUT = 'input:not([type="hidden"])'
32-
const SELECTOR_ACTIVE = '.active'
33-
const SELECTOR_BUTTON = '.btn'
31+
const SELECTOR_INPUT = 'input:not([type="hidden"])'
32+
const SELECTOR_ACTIVE = '.active'
33+
const SELECTOR_BUTTON = '.btn'
3434

35-
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
35+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
3636
const EVENT_FOCUS_BLUR_DATA_API = `focus${EVENT_KEY}${DATA_API_KEY} ` +
3737
`blur${EVENT_KEY}${DATA_API_KEY}`
38-
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
38+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
3939

4040
/**
4141
* ------------------------------------------------------------------------
@@ -85,6 +85,7 @@ class Button {
8585
if (input.type === 'checkbox' || input.type === 'radio') {
8686
input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE)
8787
}
88+
8889
$(input).trigger('change')
8990
}
9091

@@ -135,7 +136,7 @@ class Button {
135136
*/
136137

137138
$(document)
138-
.on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
139+
.on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {
139140
let button = event.target
140141
const initialButton = button
141142

@@ -158,7 +159,7 @@ $(document)
158159
}
159160
}
160161
})
161-
.on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
162+
.on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {
162163
const button = $(event.target).closest(SELECTOR_BUTTON)[0]
163164
$(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type))
164165
})

0 commit comments

Comments
 (0)