Skip to content

Commit

Permalink
feat: Add new base rules (#105)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Some new base rules have been introduced which might produce linting errors.
  • Loading branch information
jhnns authored Nov 6, 2023
1 parent c41e4e7 commit 10d01ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module.exports = {
"id-denylist": "off", // https://eslint.org/docs/rules/id-denylist
"id-length": "off", // http://eslint.org/docs/rules/id-length
"id-match": "off", // http://eslint.org/docs/rules/id-match
"import/consistent-type-specifier-style": ["warn", "prefer-top-level"], // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md
"import/dynamic-import-chunkname": "off", // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/dynamic-import-chunkname.md
"import/exports-last": "off", // https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/exports-last.md
"import/extensions": ["warn", "ignorePackages"], // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
Expand All @@ -101,6 +102,7 @@ module.exports = {
"import/no-deprecated": "off", // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
"import/no-duplicates": "warn", // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
"import/no-dynamic-require": "warn", // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
"import/no-empty-named-blocks": "warn", // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-empty-named-blocks.md
"import/no-extraneous-dependencies": [
"off",
{
Expand Down Expand Up @@ -148,6 +150,11 @@ module.exports = {
"init-declarations": "off", // http://eslint.org/docs/rules/init-declarations

"line-comment-position": "off", // http://eslint.org/docs/rules/line-comment-position
"logical-assignment-operators": [
"warn",
"always",
{ enforceForIfStatements: true },
], // http://eslint.org/docs/rules/logical-assignment-operators
"max-classes-per-file": "off", // https://eslint.org/docs/rules/max-classes-per-file
"max-depth": ["warn", 5], // http://eslint.org/docs/rules/max-depth
"max-lines": ["off", options["max-lines"]],
Expand All @@ -173,6 +180,7 @@ module.exports = {
checkLoops: false,
},
], // http://eslint.org/docs/rules/no-constant-condition
"no-constant-binary-expression": "warn", // http://eslint.org/docs/rules/no-constant-binary-expression
"no-constructor-return": "warn", // https://eslint.org/docs/rules/no-constructor-return
"no-continue": "off", // http://eslint.org/docs/rules/no-continue
"no-delete-var": "warn", // http://eslint.org/docs/rules/no-delete-var
Expand All @@ -185,6 +193,7 @@ module.exports = {
"no-empty": "warn", // http://eslint.org/docs/rules/no-empty
"no-empty-function": "off", // http://eslint.org/docs/rules/no-empty-function
"no-empty-pattern": "warn", // http://eslint.org/docs/rules/no-empty-pattern
"no-empty-static-block": "warn", // http://eslint.org/docs/rules/no-empty-static-block
"no-eq-null": "off", // http://eslint.org/docs/rules/no-eq-null
"no-eval": "warn", // http://eslint.org/docs/rules/no-eval
"no-extend-native": "warn", // http://eslint.org/docs/rules/no-extend-native
Expand Down Expand Up @@ -234,9 +243,11 @@ module.exports = {
"no-nested-ternary": "off", // http://eslint.org/docs/rules/no-nested-ternary
"no-new": "warn", // http://eslint.org/docs/rules/no-new
"no-new-func": "warn", // http://eslint.org/docs/rules/no-new-func
"no-new-native-nonconstructor": "warn", // http://eslint.org/docs/rules/no-new-native-nonconstructor
"no-new-symbol": "warn", // http://eslint.org/docs/rules/no-new-symbol
"no-new-wrappers": "warn", // http://eslint.org/docs/rules/no-new-wrappers
"no-nonoctal-decimal-escape": "error", // http://eslint.org/docs/rules/no-nonoctal-decimal-escape
"no-object-constructor": "warn", // http://eslint.org/docs/rules/no-object-constructor
"no-octal": "warn", // http://eslint.org/docs/rules/no-octal
"no-octal-escape": "warn", // http://eslint.org/docs/rules/no-octal-escape
"no-param-reassign": "off", // http://eslint.org/docs/rules/no-param-reassign
Expand Down Expand Up @@ -304,6 +315,7 @@ module.exports = {
// Handled by babel/no-unused-expressions
"no-unused-expressions": ["off", options["no-unused-expressions"]], // http://eslint.org/docs/rules/no-unused-expressions
"no-unused-labels": "warn", // http://eslint.org/docs/rules/no-unused-labels
"no-unused-private-class-members": "warn", // http://eslint.org/docs/rules/no-unused-private-class-members
"no-unused-vars": ["warn", options["no-unused-vars"]], // http://eslint.org/docs/rules/no-unused-vars
"no-use-before-define": "off", // http://eslint.org/docs/rules/no-use-before-define
"no-useless-backreference": "error", // http://eslint.org/docs/rules/no-useless-backreference
Expand Down Expand Up @@ -334,6 +346,7 @@ module.exports = {
"prefer-exponentiation-operator": "warn", // https://eslint.org/docs/rules/prefer-exponentiation-operator
"prefer-named-capture-group": "off", // https://eslint.org/docs/rules/prefer-named-capture-group
"prefer-numeric-literals": "warn", // http://eslint.org/docs/rules/prefer-numeric-literals
"prefer-object-has-own": "warn", // https://eslint.org/docs/rules/prefer-object-has-own
"prefer-object-spread": "off", // https://eslint.org/docs/rules/prefer-object-spread
"prefer-promise-reject-errors": "warn", // http://eslint.org/docs/rules/prefer-promise-reject-errors
"prefer-regex-literals": "warn", // https://eslint.org/docs/rules/prefer-regex-literals
Expand All @@ -346,6 +359,7 @@ module.exports = {
"promise/avoid-new": "off", // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/avoid-new.md
"promise/catch-or-return": ["off", { allowFinally: true }], // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/catch-or-return.md
"promise/no-callback-in-promise": "warn", // https://github.com/xjamundx/eslint-plugin-promise
"promise/no-multiple-resolved": "warn", // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/no-multiple-resolved.md
"promise/no-native": "off", // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/no-native.md
// Nesting is rarely necessary and often the sign of confusing code.
// You can often simplify it, see https://github.com/xjamundx/eslint-plugin-promise/issues/42
Expand Down
4 changes: 4 additions & 0 deletions tests/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { getMessage } from "./message.js";

class SomeClass {
#someProp = true;

logSomeProp() {
console.log(this.#someProp);
}
}

console.log(getMessage(), SomeClass);
2 changes: 2 additions & 0 deletions tests/typescript/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class SomeClass {
someMethod() {
// ...as well as regular functions.
// See styles/prefer-arrow.js for an explanation.

console.log(this.#someProp);
}

// Should be an error
Expand Down
2 changes: 0 additions & 2 deletions typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = {
"@babel/new-cap": "off", // There are some false positives with this rule (e.g. when a library is using uppercase letters) and TypeScript catches these errors anyway
"@babel/no-invalid-this": "off", // covered by @typescript-eslint/no-invalid-this
"@babel/no-unused-expressions": "off", // covered by @typescript-eslint/no-unused-expressions
"@babel/semi": "off", // covered by @typescript-eslint/semi
// "no-undef": "off", // produces false positive with some TypeScript syntax. This is caught by TypeScript anyway.
"@typescript-eslint/adjacent-overload-signatures": "warn", // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md
"@typescript-eslint/array-type": [
Expand Down Expand Up @@ -284,7 +283,6 @@ module.exports = {
},
], // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-template-expressions.md
"@typescript-eslint/return-await": ["warn", "in-try-catch"], // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
"@typescript-eslint/semi": ["warn"], // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
"@typescript-eslint/sort-type-union-intersection-members":
"off", // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md
"@typescript-eslint/strict-boolean-expressions": [
Expand Down

0 comments on commit 10d01ed

Please sign in to comment.