Skip to content

Commit

Permalink
eslint special case
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Sep 17, 2023
1 parent 557aa00 commit 248a25f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
13 changes: 7 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ module.exports = defineConfig({
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
curly: ['error'],
'linebreak-style': ['error', 'unix'],
'no-case-declarations': 'warn',
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],

...defineRules('eslint', {
curly: ['error'],
'linebreak-style': ['error', 'unix'],
'no-case-declarations': 'warn',
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
}),
...defineRules('@typescript-eslint', {
'array-type': ['error', { default: 'array-simple', readonly: 'generic' }],
'ban-ts-comment': 'error',
Expand Down
9 changes: 7 additions & 2 deletions src/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ exports.defineFlatConfig = void 0;
exports.defineConfig = (config) => config;
exports.defineFlatConfig = (config) => config;

exports.defineRules = (pluginName, rules) =>
Object.entries(rules).reduce((prev, [key, value]) => {
exports.defineRules = (pluginName, rules) => {
if (pluginName === 'eslint') {
return rules;
}

return Object.entries(rules).reduce((prev, [key, value]) => {
prev[`${pluginName}/${key}`] = value;
return prev;
}, {});
};
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export function defineFlatConfig(config) {
}

export function defineRules(pluginName, rules) {
if (pluginName === 'eslint') {
return rules;
}

return Object.entries(rules).reduce((prev, [key, value]) => {
prev[`${pluginName}/${key}`] = value;
return prev;
Expand Down

0 comments on commit 248a25f

Please sign in to comment.