Skip to content

Commit d8db5d5

Browse files
authored
Merge pull request #51 from solidjs-community/feature/allow-xmlns
Always allow xmlns and xlink namespaces
2 parents 5c0265d + e75f728 commit d8db5d5

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

docs/no-unknown-namespaces.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ let el = <div prop:scrollTop="0px" />;
7272

7373
let el = <div attr:title="title" />;
7474

75-
/* eslint solid/no-unknown-namespaces: ["error", { "allowedNamespaces": ["xmlns"] }] */
7675
let el = (
7776
<svg
7877
xmlns="http://www.w3.org/2000/svg"
79-
version="1.1"
8078
xmlns:xlink="http://www.w3.org/1999/xlink"
79+
></svg>
80+
);
81+
82+
/* eslint solid/no-unknown-namespaces: ["error", { "allowedNamespaces": ["foo"] }] */
83+
let el = (
84+
<bar
85+
foo="http://www.w3.org/2000/svg"
86+
version="1.1"
87+
foo:bar="http://www.w3.org/1999/xlink"
8188
/>
8289
);
8390

docs/reactivity.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ function createFoo(v) {}
410410
const [bar, setBar] = createSignal();
411411
createFoo({ onBar: () => bar() });
412412

413+
const [bar, setBar] = createSignal();
414+
X.createFoo(() => bar());
415+
413416
const [signal, setSignal] = createSignal(1);
414417
const element = document.getElementById("id");
415418
element.addEventListener(
@@ -492,6 +495,16 @@ css`
492495

493496
html`<div>${(props) => props.name}</div>`;
494497

498+
styled.css`
499+
color: ${(props) => props.color};
500+
`;
501+
502+
createCss`color: ${props.color}`;
503+
504+
styled.createCss`
505+
color: ${props.color};
506+
`;
507+
495508
function Component() {
496509
let canvas;
497510
return <canvas ref={canvas} />;

src/rules/no-unknown-namespaces.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { isDOMElementName } from "../utils";
33

44
const knownNamespaces = ["on", "oncapture", "use", "prop", "attr"];
55
const styleNamespaces = ["style", "class"];
6+
const otherNamespaces = ["xmlns", "xlink"];
67

78
const rule: TSESLint.RuleModule<
89
"unknown" | "style" | "component" | "component-suggest",
@@ -71,7 +72,11 @@ const rule: TSESLint.RuleModule<
7172

7273
const namespace = node.namespace?.name;
7374
if (
74-
!(knownNamespaces.includes(namespace) || explicitlyAllowedNamespaces?.includes(namespace))
75+
!(
76+
knownNamespaces.includes(namespace) ||
77+
otherNamespaces.includes(namespace) ||
78+
explicitlyAllowedNamespaces?.includes(namespace)
79+
)
7580
) {
7681
if (styleNamespaces.includes(namespace)) {
7782
context.report({

test/rules/no-unknown-namespaces.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export const cases = run("no-unknown-namespaces", rule, {
1212
`let el = <div use:X />;`,
1313
`let el = <div prop:scrollTop="0px" />;`,
1414
`let el = <div attr:title="title" />;`,
15+
`let el = <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>`,
1516
{
16-
options: [{ allowedNamespaces: ["xmlns"] }],
17-
code: `let el = <svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" />`,
17+
options: [{ allowedNamespaces: ["foo"] }],
18+
code: `let el = <bar foo="http://www.w3.org/2000/svg" version="1.1" foo:bar="http://www.w3.org/1999/xlink" />`,
1819
},
1920
],
2021
invalid: [

0 commit comments

Comments
 (0)