Skip to content

Commit 4c59a4d

Browse files
authored
feat(native): Plugin scaffold (#128)
1 parent 8d7ffba commit 4c59a4d

21 files changed

+4373
-70
lines changed

.eslintrc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"alwaysTryTypes": true,
1212
"project": "./tsconfig.json"
1313
}
14+
},
15+
"react": {
16+
"version": "detect"
1417
}
1518
},
1619
"parserOptions": {
@@ -22,7 +25,9 @@
2225
"@typescript-eslint",
2326
"eslint-plugin-import",
2427
"eslint-plugin-jsdoc",
28+
"eslint-plugin-react",
2529
"etc",
30+
"react-hooks",
2631
"sonarjs"
2732
],
2833
"extends": [
@@ -31,6 +36,8 @@
3136
"plugin:@typescript-eslint/recommended-requiring-type-checking",
3237
"plugin:etc/recommended",
3338
"plugin:import/typescript",
39+
"plugin:react/recommended",
40+
"plugin:react/jsx-runtime",
3441
"plugin:sonarjs/recommended"
3542
],
3643
"overrides": [{
@@ -176,6 +183,7 @@
176183
"jsdoc/check-alignment": "error",
177184
"jsdoc/check-indentation": ["error", { "excludeTags": ["example", "param", "returns"] }],
178185
"jsdoc/tag-lines": ["error", "any", { "startLines": 1 }],
186+
"jsx-quotes": "error",
179187
"keyword-spacing": "error",
180188
"linebreak-style": "error",
181189
"max-classes-per-file": ["error", 1],
@@ -215,6 +223,22 @@
215223
"quote-props": ["error", "as-needed"],
216224
"radix": "error",
217225
"rest-spread-spacing": "error",
226+
"react/display-name": "off",
227+
"react/hook-use-state": "error",
228+
"react/jsx-boolean-value": ["error", "always"],
229+
"react/jsx-closing-bracket-location": "error",
230+
"react/jsx-curly-spacing": ["error", { "when": "never" }],
231+
"react/jsx-equals-spacing": ["error", "never"],
232+
"react/jsx-max-props-per-line": ["error", {
233+
"maximum": 1,
234+
"when": "multiline"
235+
}],
236+
"react/jsx-no-bind": "error",
237+
"react/jsx-no-literals": "error",
238+
"react/jsx-tag-spacing": "error",
239+
"react/prop-types": "off",
240+
"react/self-closing-comp": "error",
241+
"react-hooks/rules-of-hooks": "error",
218242
"semi-spacing": "error",
219243
"sonarjs/cognitive-complexity": "off",
220244
"sonarjs/no-duplicate-string": "off",

examples/mocha/test/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react-hooks/rules-of-hooks */
12
import { usePlugin } from "@assertive-ts/core";
23
import { SymbolPlugin } from "@examples/symbol-plugin";
34
import { RootHookObject } from "mocha";

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"eslint-plugin-etc": "^2.0.3",
3131
"eslint-plugin-import": "^2.29.1",
3232
"eslint-plugin-jsdoc": "^48.2.1",
33+
"eslint-plugin-react": "^7.34.1",
34+
"eslint-plugin-react-hooks": "^4.6.0",
3335
"eslint-plugin-sonarjs": "^0.24.0",
3436
"turbo": "^1.12.4",
3537
"typescript": "^5.4.2"

packages/dom/test/unit/lib/ElementAssertion.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("[Unit] ElementAssertion.test.ts", () => {
6969

7070
context("and it is an indirect child", () => {
7171
it("returns the assertion instance", async () => {
72-
const { findByTestId } = render(<NestedElementsTestComponent/>);
72+
const { findByTestId } = render(<NestedElementsTestComponent />);
7373
const grandparent = await findByTestId("grandparent");
7474
const child = await findByTestId("child");
7575
const grandparentTest = new ElementAssertion(grandparent);
@@ -84,7 +84,7 @@ describe("[Unit] ElementAssertion.test.ts", () => {
8484

8585
context("and it is a deeply nested child", () => {
8686
it("returns the assertion instance", async () => {
87-
const { findByTestId } = render(<NestedElementsTestComponent/>);
87+
const { findByTestId } = render(<NestedElementsTestComponent />);
8888
const grandparent = await findByTestId("grandparent");
8989
const deepChild = await findByTestId("deep-child");
9090
const grandparentTest = new ElementAssertion(grandparent);
@@ -101,7 +101,7 @@ describe("[Unit] ElementAssertion.test.ts", () => {
101101
context("when element is NOT contained in ancestor element", () => {
102102
it("throws an assertion error", async () => {
103103
const notChildElement = document.createElement("span");
104-
const { findByTestId } = render(<NestedElementsTestComponent/>);
104+
const { findByTestId } = render(<NestedElementsTestComponent />);
105105
const grandparent = await findByTestId("grandparent");
106106
const grandparentTest = new ElementAssertion(grandparent);
107107

packages/dom/test/unit/lib/fixtures/nestedElementsTestComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export function NestedElementsTestComponent(): ReactElement {
88
<span>
99
<span>
1010
<span>
11-
<span data-testid="deep-child"></span>
11+
<span data-testid="deep-child" />
1212
</span>
1313
</span>
1414
</span>
1515
</span>
1616
</span>
17-
<svg data-testid="svg-element"></svg>
17+
<svg data-testid="svg-element" />
1818
</span>
1919
);
2020
}

packages/dom/test/unit/lib/fixtures/simpleTestComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ReactElement } from "react";
33
export function SimpleTestComponent(): ReactElement {
44
return (
55
<div>
6-
<button>click me</button>
6+
<button>{"click me"}</button>
77
</div>
88
);
99
}

packages/dom/test/unit/lib/fixtures/withAttributesTestComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ReactElement } from "react";
33
export function WithAttributesTestComponent(): ReactElement {
44
return (
55
<button role="button" type="submit" className="btn primary" disabled={true}>
6-
click me
6+
{"click me"}
77
</button>
88
);
99
}

packages/native/.mocharc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json.schemastore.org/mocharc",
3+
"extension": ["ts", "tsx"],
4+
"recursive": true,
5+
"require": [
6+
"ts-node/register",
7+
"react-native-testing-mocks/register",
8+
"test/setup.ts",
9+
"test/hooks.ts"
10+
],
11+
"spec": ["test/**/*.test.*"]
12+
}

packages/native/.releaserc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json.schemastore.org/semantic-release",
3+
"branches": ["main"],
4+
"plugins": [
5+
["@semantic-release/commit-analyzer", {
6+
"releaseRules": [
7+
{ "scope": "!all", "release": false },
8+
{ "scope": "!native", "release": false }
9+
]
10+
}],
11+
"@semantic-release/release-notes-generator",
12+
"semantic-release-yarn",
13+
"@semantic-release/github"
14+
],
15+
"tagFormat": "native/v${version}"
16+
}

packages/native/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Stack Builders Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)