Skip to content

Commit

Permalink
chore: bump ESLint dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Oct 11, 2024
1 parent aaaa893 commit 663497a
Show file tree
Hide file tree
Showing 18 changed files with 1,088 additions and 878 deletions.
2 changes: 1 addition & 1 deletion docs/eslint-base/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can use your discretion to disable this rule in these cases.

### [`require-yield`](https://eslint.org/docs/rules/require-yield)

- Severity: warn
- Severity: warning

For the same reasons as `require-await`, this is only set to a warning because there are cases where a generator function is semantically more appropriate.

Expand Down
6 changes: 4 additions & 2 deletions docs/eslint-base/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ Arrow functions' parentheses are always required with the default `arrowParens:

### [`curly`](https://eslint.org/docs/rules/curly)

- Severity: warning- Configuration:
- Severity: warning
- Configuration:
- Require omitting braces only when the body is a single-line statement (`"multi-or-nest"`)
- Require `if` and `else` to have consistent curly braces (`"consistent"`)

Expand Down Expand Up @@ -85,7 +86,8 @@ if (!foo)

### [`capitalized-comments`](https://eslint.org/docs/rules/capitalized-comments)

- Severity: warning- Configuration:
- Severity: warning
- Configuration:
- Always require capitalization (`"always"`)
- Allow multi-line comments (`ignoreConsecutiveComments: true`)
- Do not ignore inline comments (`ignoreInlineComments: false`)
Expand Down
6 changes: 5 additions & 1 deletion docs/eslint-base/literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Do not use `javascript:` URLs. They are a form of `eval`.

### [`no-template-curly-in-string`](https://eslint.org/docs/rules/no-template-curly-in-string)

- Severity: warning Usually, using the `${}` syntax in a string literal is a mistake. However, it's not a deadly error, so we only set it to warning.
- Severity: warning

Usually, using the `${}` syntax in a string literal is a mistake. However, it's not a deadly error, so we only set it to warning.

### [`no-useless-concat`](https://eslint.org/docs/rules/no-useless-concat)

Expand Down Expand Up @@ -156,6 +158,8 @@ Write valid regular expressions. The only case where you might want to add a dis
### [`no-misleading-character-class`](https://eslint.org/docs/rules/no-misleading-character-class)

- Severity: error
- Configuration:
- Allow character classes to use surrogate pairs if they are escaped (`allowEscape: true`)
- Related:
- `regexp/no-misleading-unicode-character`

Expand Down
2 changes: 1 addition & 1 deletion docs/eslint-base/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Despite not using type information, this rule does its best at reliably testing

- Severity: error
- Configuration:
- Check logical expressions too (`"enforceForLogicalOperands": true`)
- Check logical expressions too (`enforceForInnerExpressions: true`)

Do not cast to booleans when values are already in a boolean context.

Expand Down
6 changes: 6 additions & 0 deletions docs/eslint-base/variables-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ foo(); // Should not work
const x = 1;
```

### [`no-useless-assignment`](https://eslint.org/docs/rules/no-useless-assignment)

- Severity: error

Don't initialize a variable with a value that is immediately reassigned with something else.

### [`no-useless-rename`](https://eslint.org/docs/rules/no-useless-rename)

- Severity: error
Expand Down
34 changes: 8 additions & 26 deletions docs/typescript/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ sidebar_position: 3

We require `T[]` syntax for arrays. This is a matter of consistency. Even for very, very complex types, we still require putting `[]` at the end, instead of using `Array<>`. If the rule provides more customization, such as allowing `(T | U)[]`, we may reconsider.

### [`ban-types`](https://typescript-eslint.io/rules/ban-types)

- Severity: error
- Configuration:
- Extend defaults (`extendDefaults: true`)
- Unban `{}` (`types: { "{}": false }`)

The types listed in the default options are either dangerous or misleading. The only exception is `{}`, which in our eyes is safe to use. It may not behave as one expects, but it doesn't hinder type safety. It is also used by TypeScript in utility types.

### [`consistent-indexed-object-style`](https://typescript-eslint.io/rules/consistent-indexed-object-style)

- Severity: error
Expand Down Expand Up @@ -106,14 +97,18 @@ We don't mind whether `interface` or `type` is used. Generally:

See the base rule for more information. This extension rule prevents false positives for TypeScript-specific syntax so it is safe to use in JavaScript files too.

### [`no-empty-interface`](https://typescript-eslint.io/rules/no-empty-interface)
### [`no-empty-object-type`](https://typescript-eslint.io/rules/no-empty-object-type)

- Severity: error
- Severity: warning
- Configuration:
- Allow extended interfaces to be empty (`allowSingleExtends: true`)
- Allow extended interfaces to be empty (`allowInterfaces: "with-single-extends"`)
- Do not allow empty object literal types (`allowObjectTypes: "never"`)
- No exceptions proposed, but you can add your own (`allowWithName: undefined`)

Empty interfaces are a form of `{}`, which match any non-nullish type. However, we allow `interface X extends Y {}` as a way to alias interfaces, because then we can declaration-merge `X`.

It is only set to warning because there are cases where empty object types are useful, when you actually mean any non-nullish object. It's only an FYI for you to consider alternatives.

### [`no-redeclare`](https://typescript-eslint.io/rules/no-redeclare)

- Severity: error
Expand Down Expand Up @@ -430,13 +425,6 @@ Do not write `import { type X } from "..."`. Instead, always use `import type` i

Do not use `require` in TypeScript because if you use `const x = require(...)` then there will be no types. `import x = require(...)` is fully obscure with `esModuleInterop`. However, you may use `require` in JavaScript if you are authoring CommonJS.

### [`no-var-requires`](https://typescript-eslint.io/rules/no-var-requires)

- Severity: error
- Disabled in JavaScript

Same as above, you should not use `require` in TypeScript.

## Exports

### [`no-useless-empty-export`](https://typescript-eslint.io/rules/no-useless-empty-export)
Expand Down Expand Up @@ -575,12 +563,6 @@ Use `x as const` instead of `x as x` when `x` is a literal. This is because `as

You should never use `@ts-ignore` or `@ts-nocheck`. They completely turn off the checker and have no sense of granularity. `@ts-expect-error` is better because it requires an error to be present, but it is still dangerous an should only be applied when there cannot be any other type errors.

### [`prefer-ts-expect-error`](https://typescript-eslint.io/rules/prefer-ts-expect-error)

- Severity: error

Use `@ts-expect-error` instead of `@ts-ignore` or `@ts-nocheck`. This rule can auto-fix `@ts-ignore` to `@ts-expect-error`.

### [`triple-slash-reference`](https://typescript-eslint.io/rules/triple-slash-reference)

- Severity: error
Expand Down Expand Up @@ -608,7 +590,7 @@ for (const key of Object.keys(obj)) {

### [`no-this-alias`](https://typescript-eslint.io/rules/no-this-alias)

- Severity: warn
- Severity: warning
- Configuration:
- Allow destructuring values from `this` (`allowDestructuring: true`)
- Do not allow any particular alias (`allowedNames: []`)
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default tseslint.config(
{
languageOptions: {
parserOptions: {
project: true,
projectService: true,
},
},
},
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"lint": "eslint .",
"spellcheck": "cspell \"**\" --no-progress",
"prepare": "husky install",
"build": "yarn workspaces foreach --no-private -t -v run build",
"build": "yarn workspaces foreach -R --no-private -t -v run build",
"publish": "yarn workspaces foreach --no-private npm publish"
},
"devDependencies": {
"cspell": "^8.7.0",
"eslint": "^8.57.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"typescript": "~5.4.5"
"cspell": "^8.14.4",
"eslint": "^9.12.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"typescript": "~5.6.3"
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/create-jc-project/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { exec, outputFile, pathExists } from "./utils.js";

if (process.argv.includes("--version") || process.argv.includes("-v")) {
console.log(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: package.json is fine to be outside
(await import("../package.json", { assert: { type: "json" } })).default
.version,
Expand Down
23 changes: 11 additions & 12 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-jc",
"version": "5.2.1",
"version": "6.0.0",
"description": "Josh-Cena's personal coding style",
"type": "module",
"repository": {
Expand Down Expand Up @@ -36,23 +36,22 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-n": "^17.4.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-n": "^17.11.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-regexp": "^2.5.0",
"globals": "^15.0.0",
"typescript-eslint": "^7.8.0"
"eslint-plugin-regexp": "^2.6.0",
"globals": "^15.11.0",
"typescript-eslint": "^8.8.1"
},
"devDependencies": {
"@types/eslint-config-prettier": "^6.11.3"
},
"peerDependencies": {
"eslint": "^8.57.0"
"eslint": "^9.12.0"
}
}
5 changes: 4 additions & 1 deletion packages/eslint-config/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export default tseslint.config({
"no-extra-bind": "error",

// https://jc-verse.github.io/js-style-guide/eslint-base/operators#no-extra-boolean-cast
"no-extra-boolean-cast": ["error", { enforceForLogicalOperands: true }],
"no-extra-boolean-cast": ["error", { enforceForInnerExpressions: true }],

// https://jc-verse.github.io/js-style-guide/eslint-base/control-flow#no-extra-label
"no-extra-label": "error",
Expand Down Expand Up @@ -727,6 +727,9 @@ export default tseslint.config({
},
],

// https://jc-verse.github.io/js-style-guide/eslint-base/variables-names#no-useless-assignment
"no-useless-assignment": "error",

// https://jc-verse.github.io/js-style-guide/eslint-base/literals#no-useless-backreference
"no-useless-backreference": "error",

Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import reactPropTypesRules from "./react-prop-types.js";

function expandConfig(
config: TSESLint.FlatConfig.ConfigArray,
enabled: undefined | boolean | TSESLint.FlatConfig.FileSpec[],
enabled: undefined | boolean | (string[] | string)[],
): TSESLint.FlatConfig.ConfigArray {
if (enabled === true) return config;
if (!enabled) return [];
Expand All @@ -34,11 +34,11 @@ export default function configCreator({
reactClassComp,
reactPropTypes,
}: {
react?: boolean | TSESLint.FlatConfig.FileSpec[];
typescriptTypeCheck?: boolean | TSESLint.FlatConfig.FileSpec[];
node?: boolean | TSESLint.FlatConfig.FileSpec[];
reactClassComp?: boolean | TSESLint.FlatConfig.FileSpec[];
reactPropTypes?: boolean | TSESLint.FlatConfig.FileSpec[];
react?: boolean | (string[] | string)[];
typescriptTypeCheck?: boolean | (string[] | string)[];
node?: boolean | (string[] | string)[];
reactClassComp?: boolean | (string[] | string)[];
reactPropTypes?: boolean | (string[] | string)[];
} = {}): TSESLint.FlatConfig.ConfigArray {
return tseslint.config(
{
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/src/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ export default tseslint.config({
// We like spreading
"react/jsx-props-no-spreading": "off",

"react/jsx-props-no-spread-multi": "error",

"react/jsx-sort-props": 0,

// Formatting
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default tseslint.config({
},
},
plugins: {
// @ts-expect-error: TODO make an issue
n: nPlugin,
},
rules: {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export default tseslint.config({

"react/forbid-elements": 0,

"react/forward-ref-uses-ref": "error",

// Note that it false-positives for `const Foo: Comp = () => <></>`
"react/function-component-definition": [
"warn",
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/typescript-typecheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default tseslint.config({
},
],

"@typescript-eslint/no-deprecated": "warn",

"@typescript-eslint/no-floating-promises": [
"warn",
{
Expand All @@ -56,7 +58,7 @@ export default tseslint.config({

"@typescript-eslint/no-unnecessary-condition": [
"error",
{ allowConstantLoopConditions: true },
{ allowConstantLoopConditions: true, checkTypePredicates: true },
],

// Enums & namespaces aren't allowed anyway.
Expand Down
Loading

0 comments on commit 663497a

Please sign in to comment.