Skip to content

Commit

Permalink
modify no-unused-vars for *.js (#21)
Browse files Browse the repository at this point in the history
* modify no-unused-vars for *.js

* fix syntax error and prevent duplicate code

* changelog

* Formatting

---------

Co-authored-by: foxriver76 <moritz.heusinger@gmail.com>
Co-authored-by: Bluefox <dogafox@gmail.com>
  • Loading branch information
3 people authored Nov 17, 2024
1 parent 9bdcbd3 commit 072bd72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ It is suggested to create separate `eslint.config.mjs` files for backend and for
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**
- (@mcm1957/@foxriver76) allow unused args with `_` prefix in JavaScript too

### 0.1.7 (2024-11-13)
- (@foxriver76) Allow `require` imports for `.js` files

Expand Down
31 changes: 21 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,21 @@ const generalRules = {
'@typescript-eslint/no-unused-expressions': 'off',
};

/** Rules for js and ts files */
const jsAndTsRules = {
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
caughtErrors: 'all',
},
],
}

/** General TypeScript rules */
const tsRules = {
...jsAndTsRules,
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/unbound-method': 'off',
Expand All @@ -61,14 +74,6 @@ const tsRules = {
classes: false,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
caughtErrors: 'all',
},
],
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
Expand Down Expand Up @@ -138,8 +143,14 @@ const tsRules = {
};

/** Separate config for .js files which is applied internally */
const plainJsConfig = tseslint.configs.disableTypeChecked
plainJsConfig.rules['@typescript-eslint/no-require-imports'] = 'off';
const plainJsConfig = {
...tseslint.configs.disableTypeChecked,
rules: {
...tseslint.configs.disableTypeChecked.rules,
...jsAndTsRules,
'@typescript-eslint/no-require-imports': 'off',
}
}

/** @type {import("eslint").Linter.FlatConfig[]} */
export default tseslint.config(
Expand Down

0 comments on commit 072bd72

Please sign in to comment.