Skip to content

Commit

Permalink
tgui: another giant pr: eslint changes (#981)
Browse files Browse the repository at this point in the history
* linter change

* sorts
  • Loading branch information
jlsnow301 authored Jun 15, 2024
1 parent 2015138 commit 697ae21
Show file tree
Hide file tree
Showing 321 changed files with 1,179 additions and 1,041 deletions.
225 changes: 9 additions & 216 deletions tgui/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ plugins:
- sonarjs
- react
- unused-imports
- eslint-plugin-simple-import-sort
- eslint-plugin-typescript-sort-keys
settings:
react:
version: '18.3.1'
Expand Down Expand Up @@ -289,222 +291,6 @@ rules:
## Disallow the use of variables before they are defined
# no-use-before-define: error

## Code style
## ----------------------------------------
## Enforce linebreaks after opening and before closing array brackets
array-bracket-newline: [error, consistent]
## Enforce consistent spacing inside array brackets
array-bracket-spacing: [error, never]
## Enforce line breaks after each array element
# array-element-newline: error
## Disallow or enforce spaces inside of blocks after opening block and
## before closing block
block-spacing: [error, always]
## Enforce consistent brace style for blocks
# brace-style: [error, stroustrup, { allowSingleLine: false }]
## Enforce camelcase naming convention
# camelcase: error
## Enforce or disallow capitalization of the first letter of a comment
# capitalized-comments: error
## Require or disallow trailing commas
comma-dangle: [
error,
{
arrays: always-multiline,
objects: always-multiline,
imports: always-multiline,
exports: always-multiline,
functions: only-multiline, ## Optional on functions
},
]
## Enforce consistent spacing before and after commas
comma-spacing: [error, { before: false, after: true }]
## Enforce consistent comma style
comma-style: [error, last]
## Enforce consistent spacing inside computed property brackets
computed-property-spacing: [error, never]
## Enforce consistent naming when capturing the current execution context
# consistent-this: error
## Require or disallow newline at the end of files
# eol-last: error
## Require or disallow spacing between function identifiers and their
## invocations
func-call-spacing: [error, never]
## Require function names to match the name of the variable or property
## to which they are assigned
# func-name-matching: error
## Require or disallow named function expressions
# func-names: error
## Enforce the consistent use of either function declarations or expressions
func-style: [error, expression]
## Enforce line breaks between arguments of a function call
# function-call-argument-newline: error
## Enforce consistent line breaks inside function parentheses
## NOTE: This rule does not honor a newline on opening paren.
# function-paren-newline: [error, never]
## Disallow specified identifiers
# id-blacklist: error
## Enforce minimum and maximum identifier lengths
# id-length: error
## Require identifiers to match a specified regular expression
# id-match: error
## Enforce the location of arrow function bodies
# implicit-arrow-linebreak: error
## Enforce consistent indentation
#indent: [error, 2, { SwitchCase: 1 }]
## Enforce the consistent use of either double or single quotes in JSX
## attributes
# jsx-quotes: [error, prefer-double]
## Enforce consistent spacing between keys and values in object literal
## properties
key-spacing: [error, { beforeColon: false, afterColon: true }]
## Enforce consistent spacing before and after keywords
keyword-spacing: [error, { before: true, after: true }]
## Enforce position of line comments
# line-comment-position: error
## Enforce consistent linebreak style
# linebreak-style: error
## Require empty lines around comments
# lines-around-comment: error
## Require or disallow an empty line between class members
# lines-between-class-members: error
## Enforce a maximum depth that blocks can be nested
# max-depth: error
## Enforce a maximum line length
max-len: [
error,
{
code: 200,
## Ignore imports
ignorePattern: '^(import\s.+\sfrom\s|.*require\()',
ignoreUrls: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
},
]
## Enforce a maximum number of lines per file
# max-lines: error
## Enforce a maximum number of line of code in a function
# max-lines-per-function: error
## Enforce a maximum depth that callbacks can be nested
# max-nested-callbacks: error
## Enforce a maximum number of parameters in function definitions
# max-params: error
## Enforce a maximum number of statements allowed in function blocks
# max-statements: error
## Enforce a maximum number of statements allowed per line
# max-statements-per-line: error
## Enforce a particular style for multiline comments
# multiline-comment-style: error
## Enforce newlines between operands of ternary expressions
# multiline-ternary: [error, always-multiline]
## Require constructor names to begin with a capital letter
# new-cap: error
## Enforce or disallow parentheses when invoking a constructor with no
## arguments
# new-parens: error
## Require a newline after each call in a method chain
# newline-per-chained-call: error
## Disallow Array constructors
# no-array-constructor: error
## Disallow bitwise operators
# no-bitwise: error
## Disallow continue statements
# no-continue: error
## Disallow inline comments after code
# no-inline-comments: error
## Disallow if statements as the only statement in else blocks
# no-lonely-if: error
## Disallow mixed binary operators
# no-mixed-operators: error
## Disallow mixed spaces and tabs for indentation
# no-mixed-spaces-and-tabs: error
## Disallow use of chained assignment expressions
# no-multi-assign: error
## Disallow multiple empty lines
# no-multiple-empty-lines: error
## Disallow negated conditions
# no-negated-condition: error
## Disallow nested ternary expressions
# no-nested-ternary: error
## Disallow Object constructors
# no-new-object: error
## Disallow the unary operators ++ and --
# no-plusplus: error
## Disallow specified syntax
# no-restricted-syntax: error
## Disallow all tabs
# no-tabs: error
## Disallow ternary operators
# no-ternary: error
## Disallow trailing whitespace at the end of lines
# no-trailing-spaces: error
## Disallow dangling underscores in identifiers
# no-underscore-dangle: error
## Disallow ternary operators when simpler alternatives exist
# no-unneeded-ternary: error
## Disallow whitespace before properties
# no-whitespace-before-property: error
## Enforce the location of single-line statements
# nonblock-statement-body-position: error
## Enforce consistent line breaks inside braces
# object-curly-newline: [error, { multiline: true }]
## Enforce consistent spacing inside braces
#object-curly-spacing: [error, always]
## Enforce placing object properties on separate lines
# object-property-newline: error
## Enforce variables to be declared either together or separately in
## functions
# one-var: error
## Require or disallow newlines around variable declarations
# one-var-declaration-per-line: error
## Require or disallow assignment operator shorthand where possible
# operator-assignment: error
## Enforce consistent linebreak style for operators
#operator-linebreak: [error, before]
## Require or disallow padding within blocks
# padded-blocks: error
## Require or disallow padding lines between statements
# padding-line-between-statements: error
## Disallow using Object.assign with an object literal as the first
## argument and prefer the use of object spread instead.
# prefer-object-spread: error
## Require quotes around object literal property names
# quote-props: error
## Enforce the consistent use of either backticks, double, or single quotes
# quotes: [error, single]
## Require or disallow semicolons instead of ASI
semi: error
## Enforce consistent spacing before and after semicolons
semi-spacing: [error, { before: false, after: true }]
## Enforce location of semicolons
semi-style: [error, last]
## Require object keys to be sorted
# sort-keys: error
## Require variables within the same declaration block to be sorted
# sort-vars: error
## Enforce consistent spacing before blocks
#space-before-blocks: [error, always]
## Enforce consistent spacing before function definition opening parenthesis
#space-before-function-paren:
# [error, { anonymous: always, named: never, asyncArrow: always }]
## Enforce consistent spacing inside parentheses
#space-in-parens: [error, never]
## Require spacing around infix operators
# space-infix-ops: error
## Enforce consistent spacing before or after unary operators
# space-unary-ops: error
## Enforce consistent spacing after the // or /* in a comment
spaced-comment: [error, always]
## Enforce spacing around colons of switch statements
switch-colon-spacing: [error, { before: false, after: true }]
## Require or disallow spacing between template tags and their literals
template-tag-spacing: [error, never]
## Require or disallow Unicode byte order mark (BOM)
# unicode-bom: [error, never]
## Require parenthesis around regex literals
# wrap-regex: error

## ES6
## ----------------------------------------
## Require braces around arrow function bodies
Expand Down Expand Up @@ -760,4 +546,11 @@ rules:
## Prevents the use of unused imports.
## This could be done by enabling no-unused-vars, but we're doing this for now
unused-imports/no-unused-imports: error

# Sorting
simple-import-sort/imports: error
simple-import-sort/exports: error
typescript-sort-keys/interface: error
typescript-sort-keys/string-enum: error

extends: prettier
2 changes: 2 additions & 0 deletions tgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-sonarjs": "^1.0.3",
"eslint-plugin-typescript-sort-keys": "^3.2.0",
"eslint-plugin-unused-imports": "^3.2.0",
"file-loader": "^6.2.0",
"jest": "^29.7.0",
Expand Down
4 changes: 3 additions & 1 deletion tgui/packages/tgui-bench/entrypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* @license MIT
*/

import { setupGlobalEvents } from 'tgui/events';
import 'tgui/styles/main.scss';

import { setupGlobalEvents } from 'tgui/events';

import Benchmark from './lib/benchmark';

const sendMessage = (obj: any) => {
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/dreamseeker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { exec } from 'child_process';
import { promisify } from 'util';

import { createLogger } from './logging.js';
import { require } from './require.js';

Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui-dev-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @license MIT
*/

import { createCompiler } from './webpack.js';
import { reloadByondCache } from './reloader.js';
import { createCompiler } from './webpack.js';

const noHot = process.argv.includes('--no-hot');
const noTmp = process.argv.includes('--no-tmp');
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/link/retrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import fs from 'fs';
import { basename } from 'path';

import { createLogger } from '../logging.js';
import { require } from '../require.js';
import { resolveGlob } from '../util.js';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/link/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import http from 'http';
import { inspect } from 'util';

import { createLogger, directLog } from '../logging.js';
import { require } from '../require.js';
import { loadSourceMaps, retrace } from './retrace.js';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/reloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fs from 'fs';
import os from 'os';
import { basename } from 'path';

import { DreamSeeker } from './dreamseeker.js';
import { createLogger } from './logging.js';
import { resolveGlob, resolvePath } from './util.js';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import fs from 'fs';
import path from 'path';

import { require } from './require.js';

const globPkg = require('glob');
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fs from 'fs';
import { createRequire } from 'module';
import { dirname } from 'path';

import { loadSourceMaps, setupLink } from './link/server.js';
import { createLogger } from './logging.js';
import { reloadByondCache } from './reloader.js';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-dev-server/winreg.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { exec } from 'child_process';
import { promisify } from 'util';

import { createLogger } from './logging.js';

const logger = createLogger('winreg');
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { Button, Section, Stack } from 'tgui/components';
import { Pane } from 'tgui/layouts';

import { NowPlayingWidget, useAudio } from './audio';
import { ChatPanel, ChatTabs } from './chat';
import { useGame } from './game';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/audio/NowPlayingWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { toFixed } from 'common/math';
import { useDispatch, useSelector } from 'tgui/backend';
import { Button, Flex, Knob } from 'tgui/components';

import { useSettings } from '../settings';
import { selectAudio } from './selectors';

Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/audio/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { useDispatch, useSelector } from 'tgui/backend';

import { selectAudio } from './selectors';

export const useAudio = () => {
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/chat/ChatPageSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Section,
Stack,
} from 'tgui/components';

import { removeChatPage, toggleAcceptedType, updateChatPage } from './actions';
import { MESSAGE_TYPES } from './constants';
import { selectCurrentChatPage } from './selectors';
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/chat/ChatPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { shallowDiffers } from 'common/react';
import { Component, createRef } from 'react';
import { Button } from 'tgui/components';

import { chatRenderer } from './renderer';

export class ChatPanel extends Component {
Expand Down
7 changes: 4 additions & 3 deletions tgui/packages/tgui-panel/chat/ChatTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
*/

import { useDispatch, useSelector } from 'tgui/backend';
import { Box, Tabs, Flex, Button } from 'tgui/components';
import { changeChatPage, addChatPage } from './actions';
import { selectChatPages, selectCurrentChatPage } from './selectors';
import { Box, Button, Flex, Tabs } from 'tgui/components';

import { openChatSettings } from '../settings/actions';
import { addChatPage, changeChatPage } from './actions';
import { selectChatPages, selectCurrentChatPage } from './selectors';

const UnreadCountWidget = ({ value }) => (
<Box
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/chat/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { createAction } from 'common/redux';

import { createPage } from './model';

export const loadChat = createAction('chat/load');
Expand Down
Loading

0 comments on commit 697ae21

Please sign in to comment.