Skip to content

Commit

Permalink
fix: adding some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Oct 31, 2023
1 parent 7bfb3db commit eb3b61f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/eslint-plugin/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@readme/eslint-config"
"extends": "@readme/eslint-config",
"parserOptions": {
"ecmaVersion": 2022
}
}
4 changes: 3 additions & 1 deletion packages/eslint-plugin/rules/no-dual-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module.exports = {
create: context => {
return {
ExportDefaultDeclaration: node => {
if (!node.parent.body.filter(n => n.type === 'ExportNamedDeclaration').length) {
if (!node?.parent?.body) {
return;
} else if (!node.parent.body.filter(n => n.type === 'ExportNamedDeclaration').length) {
return;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/eslint-plugin/test/no-dual-exports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ const errorMessage =

ruleTester.run('no-dual-exports', rules['no-dual-exports'], {
valid: [
{
code: 'export class ReducerOptions {}',
},
{
code: 'export default class ReducerOptions {}',
},
{
code: 'export default function reducer(definition, opts) {}',
},
{
code: `export class ReducerOptions {}
Expand Down

0 comments on commit eb3b61f

Please sign in to comment.