Skip to content

Commit 72e8b87

Browse files
committed
Consolidate ESLint configs into root
Move general-purpose lint rules from packages/webamp/.eslintrc to the root .eslintrc so they apply to all packages consistently. This includes: - Core JavaScript best practices (no-var, prefer-const, eqeqeq, etc.) - TypeScript-specific rules (@typescript-eslint/no-unused-vars with patterns) - Prettier integration Package-specific configs now only contain rules unique to their needs: - webamp: React, import, and react-hooks plugin rules - skin-database: Extends @typescript-eslint/recommended, disables rules that conflict with existing code style - webamp-modern: Unchanged (has root: true for isolation) Also fixes lint errors in skin-database: - Consolidate duplicate imports in App.js and Feedback.js - Add radix parameter to parseInt - Prefix unused function parameters with underscore - Convert var to let/const - Fix type import for Shooter
1 parent b672de2 commit 72e8b87

File tree

11 files changed

+110
-156
lines changed

11 files changed

+110
-156
lines changed

.eslintrc

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
"jsx": true,
55
"sourceType": "module",
66
"ecmaFeatures": {
7-
"jsx": true,
8-
"experimentalObjectRestSpread": true
7+
"jsx": true
98
}
109
},
11-
"plugins": ["prettier"],
10+
"plugins": ["prettier", "@typescript-eslint"],
1211
"settings": {
13-
"react": {
14-
"version": "15.2"
15-
},
1612
"import/resolver": {
1713
"node": {
1814
"extensions": [".js", ".ts", ".tsx"]
@@ -21,27 +17,82 @@
2117
},
2218
"env": {
2319
"node": true,
24-
"amd": true,
2520
"es6": true,
2621
"jest": true
2722
},
28-
"globals": {
29-
"window": true,
30-
"document": true,
31-
"console": true,
32-
"navigator": true,
33-
"alert": true,
34-
"Blob": true,
35-
"fetch": true,
36-
"FileReader": true,
37-
"Element": true,
38-
"AudioNode": true,
39-
"MutationObserver": true,
40-
"Image": true,
41-
"location": true
42-
},
4323
"rules": {
4424
"prettier/prettier": "error",
45-
"no-constant-binary-expression": "error"
25+
"no-constant-binary-expression": "error",
26+
"block-scoped-var": "warn",
27+
"camelcase": "error",
28+
"constructor-super": "error",
29+
"dot-notation": "error",
30+
"eqeqeq": ["error", "smart"],
31+
"guard-for-in": "error",
32+
"max-depth": ["warn", 4],
33+
"max-params": ["warn", 5],
34+
"new-cap": "error",
35+
"no-caller": "error",
36+
"no-const-assign": "error",
37+
"no-debugger": "error",
38+
"no-delete-var": "error",
39+
"no-div-regex": "warn",
40+
"no-dupe-args": "error",
41+
"no-dupe-class-members": "error",
42+
"no-dupe-keys": "error",
43+
"no-duplicate-case": "error",
44+
"no-duplicate-imports": "error",
45+
"no-else-return": "error",
46+
"no-empty-character-class": "error",
47+
"no-eval": "error",
48+
"no-ex-assign": "error",
49+
"no-extend-native": "warn",
50+
"no-extra-boolean-cast": "error",
51+
"no-extra-semi": "error",
52+
"no-fallthrough": "error",
53+
"no-func-assign": "error",
54+
"no-implied-eval": "error",
55+
"no-inner-declarations": "error",
56+
"no-irregular-whitespace": "error",
57+
"no-label-var": "error",
58+
"no-labels": "error",
59+
"no-lone-blocks": "error",
60+
"no-lonely-if": "error",
61+
"no-multi-str": "error",
62+
"no-nested-ternary": "warn",
63+
"no-new-object": "error",
64+
"no-new-symbol": "error",
65+
"no-new-wrappers": "error",
66+
"no-obj-calls": "error",
67+
"no-octal": "error",
68+
"no-octal-escape": "error",
69+
"no-proto": "error",
70+
"no-redeclare": "error",
71+
"no-shadow": "warn",
72+
"no-this-before-super": "error",
73+
"no-throw-literal": "error",
74+
"no-undef-init": "error",
75+
"no-unneeded-ternary": "error",
76+
"no-unreachable": "error",
77+
"no-unused-expressions": "error",
78+
"no-useless-rename": "error",
79+
"no-var": "error",
80+
"no-with": "error",
81+
"prefer-arrow-callback": "warn",
82+
"prefer-const": "error",
83+
"prefer-spread": "error",
84+
"prefer-template": "warn",
85+
"radix": "error",
86+
"no-return-await": "error",
87+
"use-isnan": "error",
88+
"valid-typeof": "error",
89+
"@typescript-eslint/no-unused-vars": [
90+
"warn",
91+
{
92+
"argsIgnorePattern": "^_",
93+
"varsIgnorePattern": "^_",
94+
"caughtErrorsIgnorePattern": "^_"
95+
}
96+
]
4697
}
4798
}
Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
module.exports = {
2-
env: {
3-
node: true,
4-
es2021: true,
5-
jest: true,
6-
},
7-
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
8-
parser: "@typescript-eslint/parser",
9-
parserOptions: {
10-
ecmaVersion: 12,
11-
sourceType: "module",
12-
},
13-
plugins: ["@typescript-eslint"],
2+
extends: ["plugin:@typescript-eslint/recommended"],
143
rules: {
15-
// "no-console": "warn",
4+
// Disable rules that conflict with the project's style
165
"@typescript-eslint/no-var-requires": "off",
17-
"@typescript-eslint/no-require-imports": "off", // Allow require() in JS files
6+
"@typescript-eslint/no-require-imports": "off",
187
"@typescript-eslint/ban-ts-comment": "off",
198
"@typescript-eslint/explicit-module-boundary-types": "off",
209
"@typescript-eslint/no-explicit-any": "off",
2110
"@typescript-eslint/no-namespace": "off",
22-
"@typescript-eslint/no-unused-vars": [
23-
"warn",
24-
{
25-
argsIgnorePattern: "^_",
26-
varsIgnorePattern: "^_",
27-
caughtErrorsIgnorePattern: "^_",
28-
},
29-
],
11+
// Override the base no-shadow rule since it conflicts with TypeScript
12+
"no-shadow": "off",
13+
// Relax rules for this project's existing style
14+
camelcase: "off",
15+
"dot-notation": "off",
16+
eqeqeq: "off",
17+
"no-undef-init": "off",
18+
"no-return-await": "off",
19+
"prefer-arrow-callback": "off",
20+
"no-div-regex": "off",
21+
"guard-for-in": "off",
22+
"prefer-template": "off",
23+
"no-else-return": "off",
24+
"prefer-const": "off",
25+
"new-cap": "off",
3026
},
3127
ignorePatterns: ["dist/**"],
3228
};

packages/skin-database/app/(modern)/scroll/SkinScroller.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export default function SkinScroller({
6464
// When an element becomes mostly visible (> 50% intersecting)
6565
if (entry.isIntersecting && entry.intersectionRatio > 0.5) {
6666
const index = parseInt(
67-
entry.target.getAttribute("skin-index") || "0"
67+
entry.target.getAttribute("skin-index") || "0",
68+
10
6869
);
6970
setVisibleSkinIndex(index);
7071
}

packages/skin-database/app/graphql/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { handleRequest } = createYogaInstance({
1010
return new UserContext();
1111
},
1212
logger: {
13-
log: (message: string, context: Record<string, any>) => {
13+
log: (_message: string, _context: Record<string, any>) => {
1414
// console.log(message, context);
1515
},
1616
logError: (message: string, context: Record<string, any>) => {

packages/skin-database/legacy-client/src/App.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
"use client";
22
import React, { useCallback } from "react";
3-
import { connect } from "react-redux";
3+
import { connect, useSelector } from "react-redux";
44
import About from "./About";
55
import Feedback from "./Feedback";
66
import Header from "./Header";
77
import Overlay from "./Overlay";
88
import SkinTable from "./SkinTable";
99
import FocusedSkin from "./FocusedSkin";
10-
import { useSelector } from "react-redux";
1110
import * as Selectors from "./redux/selectors";
1211
import * as Actions from "./redux/actionCreators";
13-
import { ABOUT_PAGE, REVIEW_PAGE } from "./constants";
12+
import {
13+
ABOUT_PAGE,
14+
REVIEW_PAGE,
15+
SCREENSHOT_WIDTH,
16+
SKIN_RATIO,
17+
} from "./constants";
1418
import { useWindowSize, useScrollbarWidth, useActionCreator } from "./hooks";
15-
import { SCREENSHOT_WIDTH, SKIN_RATIO } from "./constants";
1619
import UploadGrid from "./upload/UploadGrid";
1720
import Metadata from "./components/Metadata";
1821
import SkinReadme from "./SkinReadme";

packages/skin-database/legacy-client/src/Feedback.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import React, { useState } from "react";
1+
import React, { useState, useCallback } from "react";
22
import { getUrl } from "./redux/selectors";
33
import * as Actions from "./redux/actionCreators";
44
import { useActionCreator } from "./hooks";
5-
6-
import { useCallback } from "react";
75
import { useSelector } from "react-redux";
86
import { fetchGraphql, gql } from "./utils";
97

packages/skin-database/legacy-client/src/components/DownloadText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useLayoutEffect, useState } from "react";
33
function DownloadText({ text, children, ...restProps }) {
44
const [url, setUrl] = useState(null);
55
useLayoutEffect(() => {
6-
var blob = new Blob([text], {
6+
let blob = new Blob([text], {
77
type: "text/plain;charset=utf-8",
88
});
99
const url = URL.createObjectURL(blob);

packages/skin-database/legacy-client/src/hashFile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import SparkMD5 from "spark-md5";
22

33
export function hashFile(file) {
4-
var blobSlice =
4+
let blobSlice =
55
File.prototype.slice ||
66
File.prototype.mozSlice ||
77
File.prototype.webkitSlice;
@@ -26,7 +26,7 @@ export function hashFile(file) {
2626
fileReader.onerror = reject;
2727

2828
function loadNext() {
29-
var start = currentChunk * chunkSize,
29+
let start = currentChunk * chunkSize,
3030
end = start + chunkSize >= file.size ? file.size : start + chunkSize;
3131

3232
fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));

packages/skin-database/legacy-client/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function museumUrlFromHash(hash) {
1313
}
1414

1515
export function getWindowSize() {
16-
var w = window,
16+
let w = window,
1717
d = document,
1818
e = d.documentElement,
1919
g = d.getElementsByTagName("body")[0],

packages/skin-database/tasks/screenshotSkin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import * as Skins from "../data/skins";
77
import * as CloudFlare from "../CloudFlare";
88
import SkinModel from "../data/SkinModel";
99

10-
const Shooter = require("../shooter");
10+
type Shooter = typeof import("../shooter");
1111

12-
export async function screenshot(skin: SkinModel, shooter: typeof Shooter) {
12+
export async function screenshot(skin: SkinModel, shooter: Shooter) {
1313
let buffer: Buffer;
1414
try {
1515
buffer = await skin.getBuffer();

0 commit comments

Comments
 (0)