[15 Minute Fix] Added the prefer-const eslint rule (#13098)
This commit is contained in:
parent
08645c782c
commit
0beacb19c9
10 changed files with 38 additions and 36 deletions
|
|
@ -54,6 +54,7 @@ module.exports = {
|
|||
],
|
||||
'react/jsx-no-target-blank': [2, { enforceDynamicLinks: 'always' }],
|
||||
'jsx-a11y/no-onchange': 'off',
|
||||
'prefer-const': ['error'],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ ahoy.configure({
|
|||
export default class AhoyController extends Controller {
|
||||
trackOverviewLink(event) {
|
||||
event.preventDefault();
|
||||
let properties = {
|
||||
const properties = {
|
||||
action: event.type,
|
||||
target: event.target.toString(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ export default class DataUpdateScriptController extends Controller {
|
|||
forceRun(event) {
|
||||
event.preventDefault();
|
||||
const id = event.target.dataset.value;
|
||||
let statusColumn = document.getElementById(
|
||||
const statusColumn = document.getElementById(
|
||||
`data_update_script_${id}_status`,
|
||||
);
|
||||
let runAtColumn = document.getElementById(
|
||||
const runAtColumn = document.getElementById(
|
||||
`data_update_script_${id}_run_at`,
|
||||
);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export default class DataUpdateScriptController extends Controller {
|
|||
|
||||
pollForScriptResponse(id, statusColumn, runAtColumn) {
|
||||
let counter = 0;
|
||||
let pollForStatus = setInterval(() => {
|
||||
const pollForStatus = setInterval(() => {
|
||||
counter++;
|
||||
this.checkForUpdatedDataScript(id, runAtColumn, statusColumn).then(
|
||||
(updatedDataScript) => {
|
||||
|
|
@ -60,12 +60,12 @@ export default class DataUpdateScriptController extends Controller {
|
|||
if (updatedDataScript.error) {
|
||||
// we need to show the html as text instead of a parsed version,
|
||||
// hence we manipulate the DOM through this longer process.
|
||||
let errorElem = document.createElement('div');
|
||||
const errorElem = document.createElement('div');
|
||||
errorElem.setAttribute('class', 'fs-xs');
|
||||
errorElem.setAttribute('id', `data_update_script_${id}_error`);
|
||||
statusColumn.appendChild(errorElem);
|
||||
|
||||
let completedErrorElem = document.getElementById(
|
||||
const completedErrorElem = document.getElementById(
|
||||
`data_update_script_${id}_error`,
|
||||
);
|
||||
completedErrorElem.innerText = updatedDataScript.error;
|
||||
|
|
@ -114,7 +114,7 @@ export default class DataUpdateScriptController extends Controller {
|
|||
}).then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json().then((json) => {
|
||||
let script = json.response;
|
||||
const script = json.response;
|
||||
if (script.status === 'succeeded' || script.status === 'failed') {
|
||||
return script;
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ export default class DataUpdateScriptController extends Controller {
|
|||
}
|
||||
|
||||
setErrorBanner(runAtColumn, statusColumn, error, bannerClass) {
|
||||
let classList = document.getElementsByClassName(
|
||||
const classList = document.getElementsByClassName(
|
||||
'data-update-script__alert',
|
||||
)[0].classList;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default class ImageUploadController extends Controller {
|
|||
|
||||
const token = document.getElementsByName('authenticity_token')[0].value;
|
||||
const image = this.fileFieldTarget.files[0];
|
||||
let formData = new FormData();
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('authenticity_token', token);
|
||||
formData.append('image', image);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ export class Chat extends Component {
|
|||
getChannelRequestInfo().then((response) => {
|
||||
const { result } = response;
|
||||
const { user_joining_requests, channel_joining_memberships } = result;
|
||||
let totalRequest =
|
||||
const totalRequest =
|
||||
user_joining_requests?.length + channel_joining_memberships?.length;
|
||||
this.setState({
|
||||
userRequestCount: totalRequest,
|
||||
|
|
@ -811,7 +811,7 @@ export class Chat extends Component {
|
|||
newUnopenedChannelIds.splice(index, 1);
|
||||
}
|
||||
|
||||
let updatedActiveChannel = this.filterForActiveChannel(
|
||||
const updatedActiveChannel = this.filterForActiveChannel(
|
||||
channelList,
|
||||
id,
|
||||
currentUserId,
|
||||
|
|
@ -1251,8 +1251,8 @@ export class Chat extends Component {
|
|||
const { notificationsPermission } = state;
|
||||
const notificationsButton = '';
|
||||
let notificationsState = '';
|
||||
let invitesButton = '';
|
||||
let joiningRequestButton = '';
|
||||
const invitesButton = '';
|
||||
const joiningRequestButton = '';
|
||||
if (notificationsPermission === 'granted') {
|
||||
notificationsState = (
|
||||
<div className="chat_chatconfig chat_chatconfig--on">
|
||||
|
|
|
|||
|
|
@ -1,35 +1,36 @@
|
|||
document.getElementById('follows_update_form').addEventListener('submit', checkChanged);
|
||||
document
|
||||
.getElementById('follows_update_form')
|
||||
.addEventListener('submit', checkChanged);
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
if (event.target && event.target.name == 'follows[][explicit_points]'){
|
||||
addChanged(event.target)
|
||||
document.addEventListener('change', (event) => {
|
||||
if (event.target && event.target.name == 'follows[][explicit_points]') {
|
||||
addChanged(event.target);
|
||||
}
|
||||
});
|
||||
|
||||
function addChanged(element) {
|
||||
element.setAttribute('changed', true);
|
||||
};
|
||||
}
|
||||
|
||||
function checkChanged(event) {
|
||||
if (document.querySelector('input[changed]')) {
|
||||
disableAllUnchanged();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function disableAllUnchanged() {
|
||||
document.querySelectorAll('div[id^="follows"]').forEach(disableUnchanged)
|
||||
};
|
||||
document.querySelectorAll('div[id^="follows"]').forEach(disableUnchanged);
|
||||
}
|
||||
|
||||
function disableUnchanged(item) {
|
||||
let inputs = item.getElementsByTagName('input')
|
||||
let id = inputs[0]
|
||||
let point = inputs[1]
|
||||
const inputs = item.getElementsByTagName('input');
|
||||
const id = inputs[0];
|
||||
const point = inputs[1];
|
||||
|
||||
if (!point.hasAttribute('changed')) {
|
||||
point.setAttribute('disabled', true)
|
||||
id.setAttribute('disabled', true)
|
||||
point.setAttribute('disabled', true);
|
||||
id.setAttribute('disabled', true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,9 +100,8 @@ export function useKeyboardShortcuts(
|
|||
// Set up key chains
|
||||
useEffect(() => {
|
||||
if (!keyChainQueue && keyChain.length === 0) return;
|
||||
let timeout;
|
||||
|
||||
timeout = window.setTimeout(() => {
|
||||
const timeout = window.setTimeout(() => {
|
||||
clearTimeout(timeout);
|
||||
setKeyChain([]);
|
||||
}, mergedOptions.timeout);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ function toggleHeaderMenu(memberMenu, navigationButton) {
|
|||
return;
|
||||
}
|
||||
|
||||
let crayonsHeaderMenuClassList = memberMenu.classList;
|
||||
const crayonsHeaderMenuClassList = memberMenu.classList;
|
||||
if (crayonsHeaderMenuClassList.contains('showing')) {
|
||||
crayonsHeaderMenuClassList.remove('showing');
|
||||
navigationButton.setAttribute('aria-expanded', 'false');
|
||||
|
|
@ -31,7 +31,7 @@ function toggleHeaderMenu(memberMenu, navigationButton) {
|
|||
crayonsHeaderMenuClassList.add('showing');
|
||||
navigationButton.setAttribute('aria-expanded', 'true');
|
||||
|
||||
let firstNavLink = document.getElementById('first-nav-link');
|
||||
const firstNavLink = document.getElementById('first-nav-link');
|
||||
if (firstNavLink) {
|
||||
setTimeout(() => {
|
||||
// focus first item on open
|
||||
|
|
@ -53,7 +53,7 @@ export function initializeTouchDevice(memberTopMenu, menuNavButton) {
|
|||
}
|
||||
|
||||
if (memberTopMenu) {
|
||||
let crayonsHeaderMenuClassList = memberTopMenu.classList;
|
||||
const crayonsHeaderMenuClassList = memberTopMenu.classList;
|
||||
|
||||
setTimeout(() => {
|
||||
closeHeaderMenu(memberTopMenu, menuNavButton);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function toggleOverflowForDocument(overflow) {
|
|||
|
||||
export function addFullScreenModeControl(elements) {
|
||||
if (elements) {
|
||||
for (let element of elements) {
|
||||
for (const element of elements) {
|
||||
element.addEventListener('click', fullScreenModeControl);
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ export function addFullScreenModeControl(elements) {
|
|||
|
||||
function removeFullScreenModeControl(elements) {
|
||||
if (elements) {
|
||||
for (let element of elements) {
|
||||
for (const element of elements) {
|
||||
element.removeEventListener('click', fullScreenModeControl);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ module.exports = {
|
|||
'import/order': ['error'],
|
||||
'import/prefer-default-export': 'off',
|
||||
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'prefer-const': ['error'],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue