Skip to content

Commit

Permalink
New. Code. JSLint checking implemented. (#335)
Browse files Browse the repository at this point in the history
* Upd. Code. ES-Lint code checking implemented.

* Fix. Code. ES-Lint notices fixed for file `spbc-upload.js`.

* Fix. Code. ES-Lint notices fixed for file `spbc-table.js`.

* Fix. Code. ES-Lint notices fixed for file `spbc-upload.js` #2.

* Fix. Code. ES-Lint notices auto fixed.

* Fix. Code. ES-Lint notices fixed for file `spbc-settings_tab--traffic_control.js`.

* Fix. Code. ES-Lint temporary ignoring unprocessed files.
  • Loading branch information
Glomberg authored Apr 21, 2024
1 parent 8a598ee commit 856011b
Show file tree
Hide file tree
Showing 23 changed files with 3,292 additions and 3,060 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: 'google',
ignorePatterns: [
'js/src/lib/*.js',
'js/src/react/*.js',
'js/src/spbc-admin.js',
'js/src/spbc-common.js',
'js/src/spbc-cookie.js',
'js/src/spbc-dashboard-widget.js',
'js/src/spbc-modal.js',
'js/src/spbc-scanner-plugin.js',
'js/src/spbc-settings.js',
'js/src/spbc-settings_tab--backups.js',
'js/src/spbc-settings_tab--scanner.js',
'js/src/spbc-settings_tab--security_log.js',
'js/src/spbc-settings_tab--settings_general.js',
'js/src/spbc-settings_tab--summary.js',
],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
},
rules: {
'indent': ['error', 4],
'max-len': ['error', {'code': 120}],
'prefer-const': 'off',
},
globals: {

},
};
49 changes: 49 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# .github/workflows/eslint.yml

name: ESLint # name of the action (displayed in the github interface)

on: # event list
push: # on push to each of these branches
branches:
- dev
- fix
- master
pull_request:
branches:
- dev
- master

env: # environment variables (available in any part of the action)
NODE_VERSION: 16

jobs: # list of things to do
linting:
name: ESLint # job name (unique id)
runs-on: ubuntu-latest # on which machine to run
steps: # list of steps
- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Code Checkout
uses: actions/checkout@v2

- name: Install Dependencies
run: npm i

- name: Code Linting
run: npm run eslint

- name: Telegram notify
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_PLUGINS_TO }}
token: ${{ secrets.TELEGRAM_REVIEWER_TOKEN }}
message: |
Hi, <strong>${{ github.actor }}</strong>! Your commit for <strong>${{ github.repository }}</strong>
contains 💯 the best solution but it have to be fixed!
<a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">Auto-Tests <strong>ESLint</strong></a> build failed ⛔!
format: html
disable_web_page_preview: true
8 changes: 4 additions & 4 deletions inc/spbc-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2173,8 +2173,8 @@ function spbc_field_traffic_control_logs__prepare_data(&$table)

foreach ($table->rows as $row) {
$ip = IP::reduceIPv6($row->ip_entry);
$allow_layout = '<a href="#" onclick="return spbc_tc__allow_ip(\'' . esc_attr($ip) . '\')" class="spbcGreen">' . esc_html__('Allow', 'security-malware-firewall') . '</a>';
$ban_layout = '<a href="#" onclick="return spbc_tc__ban_ip(\'' . esc_attr($ip) . '\')" class="spbc---red">' . esc_html__('Ban', 'security-malware-firewall') . '</a>';
$allow_layout = '<a href="#" onclick="return spbcTcAllowIp(\'' . esc_attr($ip) . '\')" class="spbcGreen">' . esc_html__('Allow', 'security-malware-firewall') . '</a>';
$ban_layout = '<a href="#" onclick="return spbcTcBanIp(\'' . esc_attr($ip) . '\')" class="spbc---red">' . esc_html__('Ban', 'security-malware-firewall') . '</a>';
$ip = "<a href='https://cleantalk.org/blacklists/{$row->ip_entry}' target='_blank'>" . esc_html($ip) . '</a>'
. '<br>'
. $allow_layout . ' | ' . $ban_layout;
Expand Down Expand Up @@ -3344,7 +3344,7 @@ function spbc_list_table__get_args_by_type($table_type)
),
'show_links' => array(
'name' => 'Show links',
'handler' => 'spbc_scanner__switch_table(this, "links");'
'handler' => 'spbcScannerSwitchTable(this, "links");'
),
),
'order_by' => array('spam_active' => 'desc'),
Expand Down Expand Up @@ -3752,7 +3752,7 @@ function spbc_list_table__get_args_by_type($table_type)
),
'show_links' => array(
'name' => 'Show links',
'handler' => 'spbc_scanner__switch_table(this, "links");'
'handler' => 'spbcScannerSwitchTable(this, "links");'
),
),
'order_by' => array('spam_active' => 'desc'),
Expand Down
2 changes: 1 addition & 1 deletion js/spbc-react-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/spbc-table.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/src/react/components/SpbctPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SpbctPage extends React.Component{
jQuery('#spbc_button__sync').on('click', function(){
jQuery('#spbc_button__sync_regular').hide();
jQuery('#spbc_button__sync_action').show();
spbc_sendAJAXRequest(
spbcSendAJAXRequest(
{action: 'spbc_sync'},
{
timeout: 25000,
Expand Down
Loading

0 comments on commit 856011b

Please sign in to comment.