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 => { module.exports = api => {
const isTest = api.env('test'); const isTest = api.env('test');
const preset = [ const preset = [
"@babel/preset-env" , { targets: 'defaults' } "@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 = [ const plugins = [
"@babel/plugin-syntax-dynamic-import", "@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-react-jsx", "@babel/plugin-transform-react-jsx",
"@babel/plugin-syntax-function-bind", "@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-function-bind", ]
"@babel/plugin-proposal-class-properties"
]
return { return {
"presets": [isTest ? testPreset: preset], "presets": [isTest ? testPreset : preset],
"plugins": plugins "plugins": plugins
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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