-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make node rules apply to cjs / mjs (#324)
- Loading branch information
Showing
3 changed files
with
45 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// @ts-ignore | ||
import nPlugin from 'eslint-plugin-n'; | ||
|
||
/** | ||
* @param {boolean} cjs | ||
* @returns {import('eslint').Linter.FlatConfig[]} | ||
*/ | ||
export function nodeRules (cjs) { | ||
return [ | ||
{ | ||
...nPlugin.configs['flat/recommended-module'], | ||
// If CommonJS, only target *.mjs, target everything but *.cjs | ||
...cjs ? { files: ['**/*.mjs'] } : { ignores: ['**/*.cjs'] }, | ||
}, | ||
{ | ||
...nPlugin.configs['flat/recommended-script'], | ||
// If CommonJS, target everything but *.mjs, else only target *.cjs | ||
...cjs ? { ignores: ['**/*.mjs'] } : { files: ['**/*.cjs'] }, | ||
}, | ||
{ | ||
name: '@voxpelli/additional/node', | ||
rules: { | ||
// Overriding | ||
'n/no-process-exit': 'off', | ||
|
||
// Adding | ||
'n/prefer-global/console': 'warn', | ||
'n/prefer-promises/fs': 'warn', | ||
'n/no-process-env': 'warn', | ||
'n/no-sync': 'error', | ||
}, | ||
}, | ||
{ | ||
name: '@voxpelli/additional/node/ts', | ||
files: ['**/*.ts'], | ||
rules: { | ||
// TODO: Remove when *.js files can be properly resolved from *.d.ts | ||
'n/no-missing-import': 'off', | ||
}, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters