Comments (6)
This works but only when done this way
"rules": {
"no-unsanitized/method": ["error", { "escape": { "methods": ["this.domSanitizer.sanitize"] } }],
"no-unsanitized/property": ["error", { "escape": { "methods": ["this.domSanitizer.sanitize"] } }],
}
from eslint-plugin-no-unsanitized.
We allow custom sanitizers through configurations.
See this testcase to check that users can allow DOMPurify:
eslint-plugin-no-unsanitized/tests/rules/property.js
Lines 154 to 164 in d50ae4d
Does that not work for you?
from eslint-plugin-no-unsanitized.
@mozfreddyb Thanks for your comment.
Could you please tell me how to add it exactly to the configuration?
I tried to add this line to the eslint rules:
"extends": ["plugin:no-unsanitized/DOM"],
"rules": {"no-unsanitized/method": ["error", { "escape": { "methods": ["DomSanitizer.sanitize"] } }]}
OR
"extends": ["plugin:no-unsanitized/DOM"],
"rules": {"no-unsanitized/method": ["error", { "escape": { "methods": ["DOMPurify.sanitize"] } }]}
but I am still getting the same eslint error:
from eslint-plugin-no-unsanitized.
In your example, you're modifying the options of the no-unsanitized/method
, which protects you from calling methods (e.g., insertAdjacentHTML()
, document.write()
, ..).
You also need to do this for the no-unsanitized/property
rule which protects properties (e.g., .innerHTML
)
from eslint-plugin-no-unsanitized.
@Abdullilah Did you end up resolving your issue? I'm leaning towards closing this issue.
from eslint-plugin-no-unsanitized.
Looks like everything works as intended here. We can repurpose the issue, if someone wants to update the documentation though.
from eslint-plugin-no-unsanitized.
Related Issues (20)
- Support bracket notation (computed member expressions) HOT 7
- Unsupported Callee of type TemplateLiteral for CallExpression HOT 5
- Unsupported Callee of type YieldExpression for CallExpression HOT 4
- Consider supporting the browser-native HTML Sanitizer API HOT 2
- unexpected FunctionExpression in normalizeMethodCall HOT 2
- unexpected FunctionExpression in normalizeMethodCall HOT 1
- unexpected AssignmentExpression in normalizeMethodCall HOT 3
- Changelogs HOT 4
- Chasing method names in assignment should take operator into account HOT 1
- TypeError: Cannot read properties of undefined (reading \'type\') HOT 4
- we should try and get information about arguments supplied as SpreadElement HOT 1
- unexpected FunctionExpression in normalizeMethodCall HOT 1
- unexpected FunctionExpression in normalizeMethodCall
- unexpected FunctionExpression in normalizeMethodCall HOT 1
- unexpected FunctionExpression in normalizeMethodCall HOT 1
- unexpected FunctionExpression in normalizeMethodCall HOT 1
- Add support for `Element.setHTMLUnsafe()`
- Feature Idea: adding another rule for HTML parsing
- Support for ESLint / Flat config HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-no-unsanitized.