Skip to content

Commit 2112b38

Browse files
committed
Added fixtures from tutorial, reduced reactivity and style-prop to warnings.
1 parent af5a268 commit 2112b38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1375
-47
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This disables some features that overlap with type checking.
4646

4747
```json
4848
{
49+
"parser": "@typescript-eslint/parser",
4950
"plugins": ["solid"],
5051
"extends": ["eslint/recommended", "plugin:solid/typescript"]
5152
}
@@ -97,7 +98,7 @@ would like to use.
9798

9899
## Versioning
99100

100-
Pre-1.0.0, the rules and the `recommended` and `typescript` configuations will be
101+
Pre-1.0.0, the rules and the `recommended` and `typescript` configuations will be
101102
stable across patch (`0.0.x`) versions, but may change across minor (`0.x`) versions.
102103
If you want to pin a minor version, use a tilde in your `package.json`.
103104

docs/no-innerhtml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This rule is **an error** by default.
1616

1717
Key | Type | Description
1818
:--- | :---: | :---
19-
allowStatic | `boolean` |
19+
allowStatic | `boolean` | if the innerHTML value is guaranteed to be a static HTML string (i.e. no user input), allow it
2020
<!-- AUTO-GENERATED-CONTENT:END -->
2121

2222
<!-- AUTO-GENERATED-CONTENT:START (CASES) -->

docs/reactivity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- AUTO-GENERATED-CONTENT:START (HEADER) -->
22
# solid/reactivity
33
Enforce that reactive expressions (props, signals, memos, etc.) are only used in tracked scopes; otherwise, they won't update the view as expected.
4-
This rule is **an error** by default.
4+
This rule is **a warning** by default.
55

66
[View source](../src/rules/reactivity.ts) · [View tests](../test/rules/reactivity.test.ts)
77

docs/style-prop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- AUTO-GENERATED-CONTENT:START (HEADER) -->
22
# solid/style-prop
33
Require CSS properties in the `style` prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, and that property values are strings, not numbers with implicit 'px' units.
4-
This rule is **an error** by default.
4+
This rule is **a warning** by default.
55

66
[View source](../src/rules/style-prop.ts) · [View tests](../test/rules/style-prop.test.ts)
77

@@ -16,8 +16,8 @@ This rule is **an error** by default.
1616

1717
Key | Type | Description
1818
:--- | :---: | :---
19-
styleProps | `Array<string>` |
20-
allowString | `boolean` |
19+
styleProps | `Array<string>` | an array of prop names to treat as a CSS style object *Default `["style"]`*.
20+
allowString | `boolean` | if allowString is set to true, this rule will not convert a style string literal into a style object (not recommended for performance)
2121
<!-- AUTO-GENERATED-CONTENT:END -->
2222

2323
<!-- AUTO-GENERATED-CONTENT:START (CASES) -->

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"eslint-plugin-import": "^2.25.3",
5353
"eslint-v6": "npm:eslint@^6.0.0",
5454
"eslint-v7": "npm:eslint@^7.0.0",
55+
"fast-glob": "^3.2.11",
5556
"fs-extra": "^10.0.0",
5657
"husky": "^7.0.0",
5758
"jest": "^27.4.4",

scripts/docs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ const buildOptions = (filename: string): string => {
6767
":--- | :---: | :---",
6868
...Object.keys(properties).map((prop) => {
6969
let type = properties[prop].type;
70-
const default_ = properties[prop].default;
70+
const _default = properties[prop].default;
7171
if (type === "array") {
7272
type = `Array<${properties[prop].items.type}>`;
7373
}
7474
return `${prop} | \`${type}\` | ${properties[prop].description ?? ""} ${
75-
default_ ? `*Default \`${default_}\`*.` : ""
75+
_default ? `*Default \`${JSON.stringify(_default)}\`*.` : ""
7676
}`;
7777
}),
7878
].join("\n");

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import noUnknownNamespaces from "./rules/no-unknown-namespaces";
77
// import noUselessKeys from './rules/no-useless-keys';
88
import preferClasslist from "./rules/prefer-classlist";
99
import preferFor from "./rules/prefer-for";
10+
// import preferShow from './rules/prefer-show';
1011
import reactivity from "./rules/reactivity";
1112
import styleProp from "./rules/style-prop";
1213

@@ -20,6 +21,7 @@ const allRules = {
2021
// noUselessKeys,
2122
"prefer-classlist": preferClasslist,
2223
"prefer-for": preferFor,
24+
// "prefer-show": preferShow,
2325
reactivity,
2426
"style-prop": styleProp,
2527
};
@@ -46,14 +48,14 @@ module.exports = {
4648
"solid/jsx-no-undef": 2,
4749
"solid/jsx-uses-vars": 2,
4850
"solid/no-unknown-namespaces": 2,
49-
// incorrect usages of innerHTML, <For />, and style are security or logic errors
51+
// incorrect usages of innerHTML and <For /> are security or logic errors
5052
"solid/no-innerhtml": [2, { allowStatic: true }],
5153
"solid/prefer-for": 2,
52-
"solid/style-prop": 2,
5354
// reactivity
5455
"solid/no-destructure": 2,
55-
"solid/reactivity": 2,
56+
"solid/reactivity": 1,
5657
// these rules are mostly style suggestions
58+
"solid/style-prop": 1,
5759
"solid/no-react-specific-props": 1,
5860
"solid/prefer-classlist": 1,
5961
},
@@ -68,14 +70,14 @@ module.exports = {
6870
// identifier usage is important
6971
"solid/jsx-no-undef": [2, { typescriptEnabled: true }],
7072
"solid/jsx-uses-vars": 2,
71-
// incorrect usages of innerHTML, <For />, and style are security or logic errors
73+
// incorrect usages of innerHTML and <For /> are security or logic errors
7274
"solid/no-innerhtml": [2, { allowStatic: true }],
7375
"solid/prefer-for": 2,
74-
"solid/style-prop": 2,
7576
// reactivity
7677
"solid/no-destructure": 2,
77-
"solid/reactivity": 2,
78+
"solid/reactivity": 1,
7879
// these rules are mostly style suggestions
80+
"solid/style-prop": 1,
7981
"solid/no-react-specific-props": 1,
8082
"solid/prefer-classlist": 1,
8183
// namespaces taken care of by TS

src/rules/no-innerhtml.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ const rule: TSESLint.RuleModule<
2222
{
2323
type: "object",
2424
properties: {
25-
// if the innerHTML value is guaranteed to be a static string (i.e. no user input), allow it
2625
allowStatic: {
26+
description:
27+
"if the innerHTML value is guaranteed to be a static HTML string (i.e. no user input), allow it",
2728
type: "boolean",
2829
},
2930
},

src/rules/prefer-show.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

src/rules/style-prop.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ const rule: TSESLint.RuleModule<
2424
{
2525
type: "object",
2626
properties: {
27-
// an array of prop names to treat as a CSS style object, defaults to ["style"]
2827
styleProps: {
28+
description: "an array of prop names to treat as a CSS style object",
29+
default: ["style"],
2930
type: "array",
3031
items: {
3132
type: "string",
3233
minItems: 1,
3334
uniqueItems: true,
3435
},
3536
},
36-
// if allowString is set to true, this rule will not convert a style string literal into a style object (not recommended for performance)
3737
allowString: {
38+
description:
39+
"if allowString is set to true, this rule will not convert a style string literal into a style object (not recommended for performance)",
3840
type: "boolean",
3941
},
4042
},

0 commit comments

Comments
 (0)