Skip to content

Commit fe7eeed

Browse files
committed
Add eslint jest plugin (firefox-devtools#5010)
1 parent df34a08 commit fe7eeed

20 files changed

Lines changed: 91 additions & 118 deletions

File tree

.eslintrc

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
22
"parser": "babel-eslint",
3-
"plugins": [
4-
"react",
5-
"mozilla",
6-
"flowtype",
7-
"babel",
8-
"prettier"
9-
],
3+
"plugins": ["react", "mozilla", "flowtype", "babel", "prettier"],
104
"globals": {
115
"atob": true,
126
"btoa": true,
@@ -35,18 +29,19 @@
3529
"extends": [
3630
"prettier",
3731
"prettier/flowtype",
38-
"prettier/react"
32+
"prettier/react",
33+
"plugin:jest/recommended"
3934
],
4035
"parserOptions": {
4136
"ecmaVersion": 2016,
4237
"sourceType": "module",
4338
"ecmaFeatures": { "jsx": true }
4439
},
4540
"env": {
46-
"es6": true,
47-
"browser": true,
48-
"commonjs": true,
49-
"jest": true
41+
"es6": true,
42+
"browser": true,
43+
"commonjs": true,
44+
"jest": true
5045
},
5146
"rules": {
5247
// These are the rules that have been configured so far to match the
@@ -68,16 +63,15 @@
6863
"react/no-direct-mutation-state": 1,
6964
"react/no-unknown-property": 1,
7065
"react/prop-types": 1,
71-
"react/sort-comp": [1, {
72-
order: [
73-
"propTypes",
74-
"everything-else",
75-
"render"
76-
]
77-
}],
66+
"react/sort-comp": [
67+
1,
68+
{
69+
order: ["propTypes", "everything-else", "render"]
70+
}
71+
],
7872

7973
// Enforce the spacing around the * in generator functions.
80-
"babel/generator-star-spacing": [2, "after"],
74+
"babel/generator-star-spacing": [2, "after"],
8175

8276
"flowtype/define-flow-type": 1,
8377
"flowtype/use-flow-type": 1,
@@ -125,7 +119,15 @@
125119
// rule is a better rule to check this.
126120
"max-depth": 0,
127121
// Maximum length of a line.
128-
"max-len": [2, 80, 2, {"ignoreUrls": true, "ignorePattern": "\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-"}],
122+
"max-len": [
123+
2,
124+
80,
125+
2,
126+
{
127+
"ignoreUrls": true,
128+
"ignorePattern": "\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-"
129+
}
130+
],
129131
// Maximum depth callbacks can be nested.
130132
"max-nested-callbacks": [2, 3],
131133
// Don't limit the number of parameters that can be used in a function.
@@ -136,7 +138,7 @@
136138
// Require a capital letter for constructors, only check if all new
137139
// operators are followed by a capital letter. Don't warn when capitalized
138140
// functions are used without the new operator.
139-
"new-cap": [2, {"capIsNew": false}],
141+
"new-cap": [2, { "capIsNew": false }],
140142
// Disallow use of the Array constructor.
141143
"no-array-constructor": 2,
142144
// Allow use of bitwise operators.
@@ -211,10 +213,13 @@
211213
// Disallow use of multiline strings (use template strings instead).
212214
"no-multi-str": 2,
213215
"prefer-template": "error",
214-
"prefer-const": ["error", {
215-
"destructuring": "all",
216-
"ignoreReadBeforeAssign": false
217-
}],
216+
"prefer-const": [
217+
"error",
218+
{
219+
"destructuring": "all",
220+
"ignoreReadBeforeAssign": false
221+
}
222+
],
218223
// Disallow reassignments of native objects.
219224
"no-native-reassign": 2,
220225
// Disallow nested ternary expressions, they make the code hard to read.
@@ -287,7 +292,7 @@
287292
// statement.
288293
"no-unreachable": 2,
289294
// Disallow global and local variables that arent used, but allow unused function arguments.
290-
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
295+
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
291296
// Allow using variables before they are defined.
292297
"no-use-before-define": 0,
293298
// We use var-only-at-top-level instead of no-var as we allow top level

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"eslint-config-prettier": "^2.3.0",
123123
"eslint-plugin-babel": "^4.1.2",
124124
"eslint-plugin-flowtype": "^2.36.0",
125+
"eslint-plugin-jest": "^21.5.0",
125126
"eslint-plugin-mozilla": "^0.4.4",
126127
"eslint-plugin-prettier": "^2.3.1",
127128
"eslint-plugin-react": "^7.2.1",

src/actions/breakpoints/tests/syncing.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe("loading the debugger", () => {
124124
pendingBreakpoint()
125125
);
126126

127-
expect(threadClient.removeBreakpoint.mock.calls.length).toBe(0);
127+
expect(threadClient.removeBreakpoint.mock.calls).toHaveLength(0);
128128
expect(update).toMatchSnapshot();
129129
});
130130

@@ -155,7 +155,7 @@ describe("loading the debugger", () => {
155155
pendingBreakpoint()
156156
);
157157

158-
expect(threadClient.removeBreakpoint.mock.calls.length).toBe(0);
158+
expect(threadClient.removeBreakpoint.mock.calls).toHaveLength(0);
159159
expect(update.breakpoint.location.line).toBe(location.line + generated);
160160
expect(update).toMatchSnapshot();
161161
});
@@ -192,7 +192,7 @@ describe("reloading debuggee", () => {
192192
reloadedSource.id,
193193
pendingBreakpoint({ location: loc1 })
194194
);
195-
expect(threadClient.removeBreakpoint.mock.calls.length).toBe(0);
195+
expect(threadClient.removeBreakpoint.mock.calls).toHaveLength(0);
196196
expect(update).toMatchSnapshot();
197197
});
198198

@@ -230,7 +230,7 @@ describe("reloading debuggee", () => {
230230
reloadedSource.id,
231231
pendingBreakpoint()
232232
);
233-
expect(threadClient.removeBreakpoint.mock.calls.length).toBe(1);
233+
expect(threadClient.removeBreakpoint.mock.calls).toHaveLength(1);
234234
expect(findScopeByName).toHaveBeenCalled();
235235
expect(update).toMatchSnapshot();
236236
});

src/actions/sources/tests/select.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("sources", () => {
4343
getOutOfScopeLocations(state) && getSourceMetaData(state, source.id)
4444
);
4545
const locations = getOutOfScopeLocations(getState());
46-
expect(locations.length).toEqual(1);
46+
expect(locations).toHaveLength(1);
4747
});
4848

4949
it("should automatically select a pending source", async () => {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { createStore, selectors, actions } from "../../utils/test-head";
2-
import expect from "expect.js";
32
describe("navigation", () => {
43
it("connect sets the debuggeeUrl", () => {
54
const { dispatch, getState } = createStore();
65
dispatch(actions.connect("http://test.com/foo"));
7-
expect(selectors.getDebuggeeUrl(getState())).to.be("http://test.com/foo");
6+
expect(selectors.getDebuggeeUrl(getState())).toEqual("http://test.com/foo");
87
});
98
});

src/actions/tests/pause.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("pause", () => {
5757
const { dispatch } = createStore(client);
5858

5959
dispatch(actions.stepIn());
60-
expect(client.stepIn.mock.calls.length).toEqual(0);
60+
expect(client.stepIn.mock.calls).toHaveLength(0);
6161
});
6262

6363
it("should step when paused", async () => {
@@ -78,7 +78,7 @@ describe("pause", () => {
7878

7979
dispatch(actions.stepIn());
8080
await dispatch(actions.resumed());
81-
expect(client.evaluate.mock.calls.length).toEqual(0);
81+
expect(client.evaluate.mock.calls).toHaveLength(0);
8282
});
8383

8484
it("resuming - will re-evaluate watch expressions", async () => {

src/client/firefox/tests/onconnect.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("firefox onConnect", () => {
5858
},
5959
actions
6060
);
61-
expect(actions._sources.length).toEqual(1);
61+
expect(actions._sources).toHaveLength(1);
6262
expect(actions._sources[0].url).toEqual("file:///tmp/s.js");
6363
});
6464
});

src/components/Editor/tests/Breakpoints.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ describe("Breakpoints Component", () => {
3333
const breakpoints = I.Map({ id1: { location: { sourceId } } });
3434

3535
const { component, props } = render({ breakpoints });
36-
expect(component.find("Breakpoint").length).toBe(props.breakpoints.size);
36+
expect(component.find("Breakpoint")).toHaveLength(props.breakpoints.size);
3737
});
3838

3939
it("should render breakpoints with columns", async () => {
4040
const sourceId = "server1.conn1.child1/source1";
4141
const breakpoints = I.Map({ id1: { location: { column: 2, sourceId } } });
4242

4343
const { component, props } = render({ breakpoints });
44-
expect(component.find("Breakpoint").length).toBe(props.breakpoints.size);
44+
expect(component.find("Breakpoint")).toHaveLength(props.breakpoints.size);
4545
expect(component).toMatchSnapshot();
4646
});
4747
});

src/components/ProjectSearch/textSearch/tests/__snapshots__/textSearch.spec.js.snap

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,3 @@ exports[`project search - highlightMatches simple 1`] = `
1919
/>
2020
</span>
2121
`;
22-
23-
exports[`project search - highlightMatches simple 2`] = `
24-
<span
25-
className="line-value"
26-
>
27-
<span
28-
className="line-match"
29-
>
30-
lets
31-
</span>
32-
<span
33-
className="query-match"
34-
>
35-
foo
36-
</span>
37-
<span
38-
className="line-match"
39-
>
40-
and then baa
41-
</span>
42-
</span>
43-
`;

src/components/ProjectSearch/textSearch/tests/textSearch.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,3 @@ describe("project search - highlightMatches", () => {
1010
expect(highlightMatches(lineMatch)).toMatchSnapshot();
1111
});
1212
});
13-
describe("project search - highlightMatches", () => {
14-
it("simple", () => {
15-
const lineMatch = {
16-
value: "lets foo and then baa",
17-
column: 5,
18-
match: "foo"
19-
};
20-
expect(highlightMatches(lineMatch)).toMatchSnapshot();
21-
});
22-
});

0 commit comments

Comments
 (0)