Skip to content

Commit

Permalink
allow 'require' imports for '.js' files (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 authored Nov 13, 2024
1 parent 00912d0 commit 6f5f8fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ 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**
- (@foxriver76) Allow `require` imports for `.js` files

### 0.1.6 (2024-09-16)

- (@GermanBluefox) Enforce the use of template literals instead of string concatenation: "Hello, " + name + "!" => `Hello, ${name}!`
Expand Down
10 changes: 9 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import globals from 'globals';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';

/**
* Rules for all JSDOC plugin usages
*/
Expand Down Expand Up @@ -136,6 +137,10 @@ const tsRules = {
'@typescript-eslint/consistent-type-exports': 'error',
};

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

/** @type {import("eslint").Linter.FlatConfig[]} */
export default tseslint.config(
eslint.configs.recommended,
Expand Down Expand Up @@ -163,7 +168,7 @@ export default tseslint.config(
},
{
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
...plainJsConfig,
},
);

Expand All @@ -177,6 +182,9 @@ export const esmConfig = [
},
];

/**
* Config for React projects
*/
export const reactConfig = [
{
plugins: {
Expand Down

0 comments on commit 6f5f8fc

Please sign in to comment.