Skip to content

Commit

Permalink
Comply to the new rules
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Sep 10, 2020
1 parent 1c37a2b commit 3be5859
Show file tree
Hide file tree
Showing 35 changed files with 614 additions and 582 deletions.
4 changes: 2 additions & 2 deletions build/build-plugins.js
Expand Up @@ -39,7 +39,7 @@ const bsPlugins = {
}
const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/'

const build = async (plugin) => {
const build = async plugin => {
console.log(`Building ${plugin} plugin...`)

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

const main = async () => {
try {
await Promise.all(Object.keys(bsPlugins).map((plugin) => build(plugin)))
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
} catch (error) {
console.error(error)

Expand Down
13 changes: 9 additions & 4 deletions build/change-version.js
Expand Up @@ -30,18 +30,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
if (excludedDirectories.has(path.parse(directory).base)) {
return
}

fs.readdir(directory, (err, names) => {
if (err) {
errback(err)
return
}
names.forEach((name) => {

names.forEach(name => {
const filepath = path.join(directory, name)
fs.lstat(filepath, (err, stats) => {
if (err) {
process.nextTick(errback, err)
return
}

if (stats.isDirectory()) {
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
} else if (stats.isFile()) {
Expand All @@ -55,18 +58,19 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
original = new RegExp(regExpQuote(original), 'g')
replacement = regExpQuoteReplacement(replacement)
const updateFile = DRY_RUN ? (filepath) => {
const updateFile = DRY_RUN ? filepath => {
if (allowedExtensions.has(path.parse(filepath).ext)) {
console.log(`FILE: ${filepath}`)
} else {
console.log(`EXCLUDED:${filepath}`)
}
} : (filepath) => {
} : filepath => {
if (allowedExtensions.has(path.parse(filepath).ext)) {
sh.sed('-i', original, replacement, filepath)
}
}
walkAsync(directory, excludedDirectories, updateFile, (err) => {

walkAsync(directory, excludedDirectories, updateFile, err => {
console.error('ERROR while traversing directory!:')
console.error(err)
process.exit(1)
Expand All @@ -79,6 +83,7 @@ function main(args) {
console.error('Got arguments:', args)
process.exit(1)
}

const oldVersion = args[0]
const newVersion = args[1]
const EXCLUDED_DIRS = new Set([
Expand Down
2 changes: 1 addition & 1 deletion build/generate-sri.js
Expand Up @@ -49,7 +49,7 @@ const files = [
}
]

files.forEach((file) => {
files.forEach(file => {
fs.readFile(file.file, 'utf8', (err, data) => {
if (err) {
throw err
Expand Down
2 changes: 1 addition & 1 deletion build/postcss.config.js
@@ -1,6 +1,6 @@
'use strict'

module.exports = (ctx) => ({
module.exports = ctx => ({
map: ctx.file.dirname.includes('examples') ? false : {
inline: false,
annotation: true,
Expand Down
2 changes: 1 addition & 1 deletion build/zip-examples.js
Expand Up @@ -43,7 +43,7 @@ sh.cp('-f', [
sh.rm(`${folderName}/index.html`)

// get all examples' HTML files
sh.find(`${folderName}/**/*.html`).forEach((file) => {
sh.find(`${folderName}/**/*.html`).forEach(file => {
const fileContents = sh.cat(file)
.toString()
.replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')
Expand Down
30 changes: 15 additions & 15 deletions js/src/alert.js
Expand Up @@ -14,22 +14,22 @@ import Util from './util'
* ------------------------------------------------------------------------
*/

const NAME = 'alert'
const VERSION = '4.5.2'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const NAME = 'alert'
const VERSION = '4.5.2'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]

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

const EVENT_CLOSE = `close${EVENT_KEY}`
const EVENT_CLOSED = `closed${EVENT_KEY}`
const EVENT_CLOSE = `close${EVENT_KEY}`
const EVENT_CLOSED = `closed${EVENT_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`

const CLASS_NAME_ALERT = 'alert'
const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'
const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'

/**
* ------------------------------------------------------------------------
Expand Down Expand Up @@ -74,7 +74,7 @@ class Alert {

_getRootElement(element) {
const selector = Util.getSelectorFromElement(element)
let parent = false
let parent = false

if (selector) {
parent = document.querySelector(selector)
Expand Down Expand Up @@ -105,7 +105,7 @@ class Alert {
const transitionDuration = Util.getTransitionDurationFromElement(element)

$(element)
.one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))
.one(Util.TRANSITION_END, event => this._destroyElement(element, event))
.emulateTransitionEnd(transitionDuration)
}

Expand All @@ -121,7 +121,7 @@ class Alert {
static _jQueryInterface(config) {
return this.each(function () {
const $element = $(this)
let data = $element.data(DATA_KEY)
let data = $element.data(DATA_KEY)

if (!data) {
data = new Alert(this)
Expand Down Expand Up @@ -163,9 +163,9 @@ $(document).on(
* ------------------------------------------------------------------------
*/

$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => {
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface
}
Expand Down
35 changes: 18 additions & 17 deletions js/src/button.js
Expand Up @@ -13,29 +13,29 @@ import $ from 'jquery'
* ------------------------------------------------------------------------
*/

const NAME = 'button'
const VERSION = '4.5.2'
const DATA_KEY = 'bs.button'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const NAME = 'button'
const VERSION = '4.5.2'
const DATA_KEY = 'bs.button'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]

const CLASS_NAME_ACTIVE = 'active'
const CLASS_NAME_BUTTON = 'btn'
const CLASS_NAME_FOCUS = 'focus'
const CLASS_NAME_FOCUS = 'focus'

const SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'
const SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'
const SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'
const SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'
const SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn'
const SELECTOR_INPUT = 'input:not([type="hidden"])'
const SELECTOR_ACTIVE = '.active'
const SELECTOR_BUTTON = '.btn'
const SELECTOR_INPUT = 'input:not([type="hidden"])'
const SELECTOR_ACTIVE = '.active'
const SELECTOR_BUTTON = '.btn'

const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
const EVENT_FOCUS_BLUR_DATA_API = `focus${EVENT_KEY}${DATA_API_KEY} ` +
`blur${EVENT_KEY}${DATA_API_KEY}`
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`

/**
* ------------------------------------------------------------------------
Expand Down Expand Up @@ -85,6 +85,7 @@ class Button {
if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE)
}

$(input).trigger('change')
}

Expand Down Expand Up @@ -135,7 +136,7 @@ class Button {
*/

$(document)
.on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
.on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {
let button = event.target
const initialButton = button

Expand All @@ -158,7 +159,7 @@ $(document)
}
}
})
.on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
.on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {
const button = $(event.target).closest(SELECTOR_BUTTON)[0]
$(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type))
})
Expand Down

0 comments on commit 3be5859

Please sign in to comment.