Remove function binding usage
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/tests Pipeline failed

This commit is contained in:
Sonny Bakker 2025-02-08 10:05:45 +01:00
parent 34afcc02b6
commit 1a54fdbcd1
6 changed files with 21 additions and 35 deletions

View file

@ -1,23 +1,21 @@
module.exports = api => {
const isTest = api.env('test');
const preset = [
"@babel/preset-env" , { targets: 'defaults' }
const preset = [
"@babel/preset-env", { targets: 'defaults' }
];
const testPreset = [
"@babel/preset-env", { targets: { node: process.versions.node } }
];
const testPreset = [
"@babel/preset-env", { targets: { node: process.versions.node } }
];
const plugins = [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-react-jsx",
"@babel/plugin-syntax-function-bind",
"@babel/plugin-proposal-function-bind",
"@babel/plugin-proposal-class-properties"
]
const plugins = [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-react-jsx",
"@babel/plugin-proposal-class-properties"
]
return {
"presets": [isTest ? testPreset: preset],
"plugins": plugins
}
return {
"presets": [isTest ? testPreset : preset],
"plugins": plugins
}
}

View file

@ -1,6 +1,4 @@
class Selector {
onClick = ::this.onClick;
inputs = [];
constructor() {
@ -11,7 +9,7 @@ class Selector {
selectAllInput.onchange = this.onClick;
}
onClick(e) {
onClick = (e) => {
const targetValue = e.target.checked;
this.inputs.forEach(input => {

View file

@ -9,10 +9,6 @@ import Messages from '../../components/Messages.js';
import Sidebar from '../../components/Sidebar.js';
class App extends React.Component {
selectCategory = ::this.selectCategory;
deselectCategory = ::this.deselectCategory;
deleteCategory = ::this.deleteCategory;
constructor(props) {
super(props);
@ -24,15 +20,15 @@ class App extends React.Component {
};
}
selectCategory(categoryId) {
selectCategory = (categoryId) => {
this.setState({ selectedCategoryId: categoryId });
}
deselectCategory() {
deselectCategory = () => {
this.setState({ selectedCategoryId: null });
}
deleteCategory(categoryId) {
deleteCategory = (categoryId) => {
const url = `/api/categories/${categoryId}/`;
const options = {
method: 'DELETE',

View file

@ -1,8 +1,6 @@
import React from 'react';
export default class ScrollTop extends React.Component {
scrollListener = ::this.scrollListener;
state = {
listenerAttached: false,
showTop: false,
@ -17,7 +15,7 @@ export default class ScrollTop extends React.Component {
}
}
scrollListener() {
scrollListener = () => {
const postList = this.props.postListNode;
const elementEnd =
postList.scrollTop + postList.offsetHeight >= postList.scrollHeight;

View file

@ -4,13 +4,11 @@ import { isEqual } from 'lodash';
import { fetchPostsBySection, fetchSavedPosts } from '../../actions/posts.js';
import { SAVED_TYPE } from '../../constants.js';
import { filterPosts } from './filters.js';
import LoadingIndicator from '../../../../components/LoadingIndicator.js';
import PostItem from './PostItem.js';
class PostList extends React.Component {
handleIntersect = ::this.handleIntersect;
lastPostRef = null;
observer = null;
@ -33,7 +31,7 @@ class PostList extends React.Component {
this.observer.disconnect();
}
handleIntersect(entries) {
handleIntersect = (entries) => {
entries.every(entry => {
if (entry.isIntersecting) {
this.observer.unobserve(entry.target);

View file

@ -5,9 +5,7 @@ import Cookies from 'js-cookie';
import { markRead } from '../../actions/selected.js';
class ReadButton extends React.Component {
markSelectedRead = ::this.markSelectedRead;
markSelectedRead() {
markSelectedRead = () => {
const token = Cookies.get('csrftoken');
if (this.props.selected.unread > 0) {