Skip to content

TypeError: Cannot read properties of undefined (reading 'replace') #110

@armanozak

Description

@armanozak

First of all, thank you very much for this plugin. It has saved us a lot of time.

The cleanRuleRawsBefore function replaces multiple new lines from the before property of a node's raws, but results in a type error same as the title of this issue when the property is missing.

The error is caused by this line: https://github.com/elchininet/postcss-rtlcss/blob/master/src/utilities/rules.ts#L165

The following change fixes the error:

node.raws.before = '\n\n' + (node.raws.before ? node.raws.before.replace(/\n/g, '') : '');

Please let me know if you would like me to create a PR.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions