Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure ESLint's own rules #1815

Merged
merged 3 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 239 additions & 6 deletions config/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default [
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
console: "readonly",
URL: "readonly",
},
},
},
{
Expand All @@ -35,7 +39,7 @@ export default [
// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-access": ["off"],
"jsdoc/check-alignment": ["error"],
"jsdoc/check-examples": ["off"], // TODO: enable & configure when possible
"jsdoc/check-examples": ["off"],
Comment on lines -38 to +42
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-evaluating this TODO as part of this PR.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule still does not work as of jsdoc/[email protected] so I'll leave it disabled.

I won't create an issue to enable this because I could not find a suitable way to track when this can be enabled again.

"jsdoc/check-indentation": [
"error",
{
Expand Down Expand Up @@ -270,23 +274,23 @@ export default [
tags: [
"example",

// file
// File
"overview",
"module",
"version",
"license",

// function
// Function
"param",
"returns",
"throws",
"since",

// constant
// Constant
"constant",
"type",

// misc
// Miscellaneous
"deprecated",
],
},
Expand Down Expand Up @@ -536,6 +540,220 @@ export default [
files: ["**/*.js"],
plugins: { unicorn },
rules: {
"accessor-pairs": ["error"],
"array-callback-return": ["error"],
"arrow-body-style": ["error"],
"block-scoped-var": ["error"],
camelcase: ["error"],
"capitalized-comments": [
"error",
"always",
{
ignoreConsecutiveComments: true,
},
],
"class-methods-use-this": ["off"],
complexity: ["error"],
"consistent-return": ["off"],
"consistent-this": ["error"],
"constructor-super": ["error"],
curly: ["error"],
"default-case-last": ["error"],
"default-case": ["off"],
"default-param-last": ["error"],
"dot-notation": ["error"],
eqeqeq: ["error"],
"for-direction": ["error"],
"func-name-matching": ["error"],
"func-names": ["error"],
"func-style": ["off"],
"getter-return": ["error"],
"grouped-accessor-pairs": ["error"],
"guard-for-in": ["error"],
"id-denylist": ["error"],
"id-length": ["error"],
"id-match": ["error"],
"init-declarations": ["off"],
"logical-assignment-operators": ["error"],
"max-classes-per-file": ["off"],
"max-depth": ["error"],
"max-lines": ["off"],
"max-lines-per-function": ["off"],
"max-nested-callbacks": ["error"],
"max-params": ["error"],
"max-statements": ["off"],
"new-cap": ["error"],
"no-alert": ["error"],
"no-array-constructor": ["error"],
"no-async-promise-executor": ["error"],
"no-await-in-loop": ["error"],
"no-bitwise": ["error"],
"no-caller": ["error"],
"no-case-declarations": ["error"],
"no-class-assign": ["error"],
"no-compare-neg-zero": ["error"],
"no-cond-assign": ["error"],
"no-console": ["error"],
"no-constant-binary-expression": ["error"],
"no-constant-condition": ["error"],
"no-const-assign": ["error"],
"no-constructor-return": ["error"],
"no-continue": ["off"],
"no-control-regex": ["off"],
"no-debugger": ["error"],
"no-delete-var": ["error"],
"no-div-regex": ["error"],
"no-dupe-args": ["error"],
"no-dupe-class-members": ["error"],
"no-dupe-else-if": ["error"],
"no-dupe-keys": ["error"],
"no-duplicate-case": ["error"],
"no-duplicate-imports": ["error"],
"no-else-return": ["off"],
"no-empty-character-class": ["error"],
"no-empty-function": ["error"],
"no-empty": ["error"],
"no-empty-pattern": ["error"],
"no-empty-static-block": ["error"],
"no-eq-null": ["error"],
"no-eval": ["error"],
"no-ex-assign": ["error"],
"no-extend-native": ["error"],
"no-extra-bind": ["error"],
"no-extra-boolean-cast": ["error"],
"no-extra-label": ["error"],
"no-fallthrough": ["error"],
"no-func-assign": ["error"],
"no-global-assign": ["error"],
"no-implicit-coercion": ["error"],
"no-implicit-globals": ["error"],
"no-implied-eval": ["error"],
"no-import-assign": ["error"],
"no-inline-comments": ["off"],
"no-inner-declarations": ["error"],
"no-invalid-regexp": ["error"],
"no-invalid-this": ["error"],
"no-irregular-whitespace": ["error"],
"no-iterator": ["error"],
"no-labels": ["error"],
"no-label-var": ["error"],
"no-lone-blocks": ["error"],
"no-lonely-if": ["off"],
"no-loop-func": ["error"],
"no-loss-of-precision": ["error"],
"no-magic-numbers": [
"error",
{
ignore: [0, 1, 0xa0],
},
],
"no-misleading-character-class": ["error"],
"no-multi-assign": ["error"],
"no-multi-str": ["error"],
"no-negated-condition": ["error"],
"no-nested-ternary": ["off"],
"no-new-func": ["error"],
"no-new": ["error"],
"no-new-native-nonconstructor": ["error"],
"no-new-wrappers": ["error"],
"no-nonoctal-decimal-escape": ["error"],
"no-obj-calls": ["error"],
"no-object-constructor": ["error"],
"no-octal-escape": ["error"],
"no-octal": ["error"],
"no-param-reassign": ["off"],
"no-plusplus": ["error"],
"no-promise-executor-return": ["error"],
"no-proto": ["error"],
"no-prototype-builtins": ["error"],
"no-redeclare": ["error"],
"no-regex-spaces": ["error"],
"no-restricted-exports": ["error"],
"no-restricted-globals": ["error"],
"no-restricted-imports": ["error"],
"no-restricted-properties": ["error"],
"no-restricted-syntax": ["error"],
"no-return-assign": ["error"],
"no-script-url": ["error"],
"no-self-assign": ["error"],
"no-self-compare": ["error"],
"no-sequences": ["error"],
"no-setter-return": ["error"],
"no-shadow": ["off"],
"no-shadow-restricted-names": ["error"],
"no-sparse-arrays": ["error"],
"no-template-curly-in-string": ["error"],
"no-ternary": ["off"],
"no-this-before-super": ["error"],
"no-throw-literal": ["error"],
"no-undefined": ["off"],
"no-undef-init": ["error"],
"no-undef": ["error"],
"no-underscore-dangle": ["off"],
"no-unexpected-multiline": ["error"],
"no-unmodified-loop-condition": ["error"],
"no-unneeded-ternary": ["off"],
"no-unreachable-loop": ["error"],
"no-unreachable": ["error"],
"no-unsafe-finally": ["error"],
"no-unsafe-negation": ["error"],
"no-unsafe-optional-chaining": ["error"],
"no-unused-expressions": ["error"],
"no-unused-labels": ["error"],
"no-unused-private-class-members": ["error"],
"no-unused-vars": [
"error",
{
argsIgnorePattern: "_.+",
},
],
"no-use-before-define": ["off"],
"no-useless-assignment": ["error"],
"no-useless-backreference": ["error"],
"no-useless-call": ["error"],
"no-useless-catch": ["error"],
"no-useless-computed-key": ["error"],
"no-useless-concat": ["error"],
"no-useless-constructor": ["off"],
"no-useless-escape": ["error"],
"no-useless-rename": ["error"],
"no-useless-return": ["error"],
"no-var": ["error"],
"no-void": ["error"],
"no-warning-comments": ["error"],
"no-with": ["error"],
"object-shorthand": ["error"],
"one-var": ["off"],
"operator-assignment": ["error"],
"prefer-arrow-callback": ["error"],
"prefer-const": ["error"],
"prefer-destructuring": ["off"],
"prefer-exponentiation-operator": ["error"],
"prefer-named-capture-group": ["off"],
"prefer-numeric-literals": ["error"],
"prefer-object-has-own": ["off"],
"prefer-object-spread": ["error"],
"prefer-promise-reject-errors": ["error"],
"prefer-regex-literals": ["error"],
"prefer-rest-params": ["error"],
"prefer-spread": ["error"],
"prefer-template": ["error"],
radix: ["error"],
"require-atomic-updates": ["error"],
"require-await": ["error"],
"require-unicode-regexp": ["error"],
"require-yield": ["error"],
"sort-imports": ["off"],
"sort-keys": ["off"],
"sort-vars": ["off"],
strict: ["error"],
"symbol-description": ["off"],
"unicode-bom": ["error"],
"use-isnan": ["error"],
"valid-typeof": ["error"],
"vars-on-top": ["error"],
yoda: ["error"],

// https://github.com/sindresorhus/eslint-plugin-unicorn#readme
"unicorn/better-regex": ["error"],
"unicorn/catch-error-name": ["error"],
Expand Down Expand Up @@ -699,6 +917,16 @@ export default [
files: ["test/**/*.js"],
plugins: { ava, jsdoc },
rules: {
"guard-for-in": ["off"],
"id-length": [
"error",
{
exceptions: ["_", "t"],
},
],
"no-magic-numbers": ["off"],
"max-params": ["off"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-values": [
"error",
Expand Down Expand Up @@ -728,7 +956,7 @@ export default [
"ava/no-unknown-modifiers": ["error"],
"ava/prefer-async-await": ["error"],
"ava/prefer-power-assert": ["off"],
"ava/prefer-t-regex": ["off"], // TODO: disabled because of incompatibility with ESLint v9
"ava/prefer-t-regex": ["error"],
"ava/test-title": ["error"],
"ava/test-title-format": [
"error",
Expand All @@ -751,6 +979,9 @@ export default [
files: [".github/**/*.js", "script/**/*.js"],
plugins: { jsdoc, unicorn },
rules: {
"no-console": ["off"],
"no-magic-numbers": ["off"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-values": [
"error",
Expand All @@ -769,6 +1000,8 @@ export default [
files: ["config/**/*"],
plugins: { jsdoc },
rules: {
"no-magic-numbers": ["off"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/require-file-overview": ["off"],
"jsdoc/require-jsdoc": ["off"],
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"depreman": "0.3.4",
"dotenv": "16.3.1",
"eslint": "9.14.0",
"eslint-plugin-ava": "15.0.0",
"eslint-plugin-ava": "15.0.1",
"eslint-plugin-depend": "0.12.0",
"eslint-plugin-jsdoc": "50.4.1",
"eslint-plugin-regexp": "2.6.0",
Expand Down
12 changes: 7 additions & 5 deletions script/release/bump-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ const month = _month < 10 ? `0${_month}` : _month;
const _day = date.getDate();
const day = _day < 10 ? `0${_day}` : _day;

const updatedChangelog =
changelog.slice(0, unreleasedTitleIndex + STR_UNRELEASED.length) +
`\n\n${STR_NO_CHANGES}` +
`\n\n## [${version}] - ${year}-${month}-${day}` +
changelog.slice(unreleasedTitleIndex + STR_UNRELEASED.length);
const updatedChangelog = `${changelog.slice(0, unreleasedTitleIndex + STR_UNRELEASED.length)}

${STR_NO_CHANGES}

## [${version}] - ${year}-${month}-${day}
${changelog.slice(unreleasedTitleIndex + STR_UNRELEASED.length + 1)}
`;

fs.writeFileSync(changelogFile, updatedChangelog);
8 changes: 5 additions & 3 deletions test/_arbitraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const process = () =>
fc
.record({
abort: fc.func(fc.constant(undefined)),
allowedNodeEnvironmentFlags: fc.array(fc.string()).map((v) => new Set(v)),
allowedNodeEnvironmentFlags: fc
.array(fc.string())
.map((flags) => new Set(flags)),
arch: fc.constantFrom(
"arm",
"arm64",
Expand Down Expand Up @@ -233,7 +235,7 @@ export const unsupportedUnixShell = () =>
windowsShell(),
fc
.stringMatching(/^[0-9A-Za-z]+$/u)
.filter((v) => !constants.shellsUnix.includes(v)),
.filter((shell) => !constants.shellsUnix.includes(shell)),
);

/**
Expand All @@ -247,7 +249,7 @@ export const unsupportedWindowsShell = () =>
unixShell(),
fc
.stringMatching(/^[0-9A-Za-z]+\.exe$/u)
.filter((v) => !constants.shellsWindows.includes(v)),
.filter((shell) => !constants.shellsWindows.includes(shell)),
);

/**
Expand Down
Loading