-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mobxjs:main' into main
- Loading branch information
Showing
29 changed files
with
624 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,6 @@ jobs: | |
run: yarn coverage | ||
|
||
- name: Upload to coveralls | ||
uses: coverallsapp/[email protected].1 | ||
uses: coverallsapp/[email protected].4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
packages/eslint-plugin-mobx/__tests__/TODO-missing-observer.js
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/eslint-plugin-mobx/__tests__/TODO-no-anonymous-observer.js
This file was deleted.
Oops, something went wrong.
7 changes: 2 additions & 5 deletions
7
packages/eslint-plugin-mobx/__tests__/exhaustive-make-observable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
packages/eslint-plugin-mobx/__tests__/missing-make-observable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { getRuleTester } from "./utils/get-rule-tester"; | ||
|
||
import rule from "../src/missing-observer.js" | ||
|
||
const tester = getRuleTester(); | ||
|
||
const valids = [ | ||
"observer(function Named() { });", | ||
"const foo = observer(function Named() { })", | ||
"const Anonym = observer(function () { });", | ||
"const Arrow = observer(() => { });", | ||
"function notCmp() { }", | ||
"const notCmp = function notCmp() { }", | ||
"const notCmp = function () { }", | ||
"const notCmp = () => { }", | ||
"class NotCmp { }", | ||
"class NotCmp extends Foo { }", | ||
"class NotCmp extends React.Foo { }", | ||
"const Cmp = observer(class Cmp extends React.Component { })", | ||
"const Cmp = observer(class Cmp extends Component { })", | ||
"const Cmp = observer(class extends React.Component { })", | ||
"const Cmp = observer(class extends Component { })" | ||
] | ||
|
||
const invalids = [ | ||
["function Named() { }", "const Named = observer(function Named() { })"], | ||
["const foo = function Named() { }", "const foo = observer(function Named() { })"], | ||
["const Anonym = function () { };", "const Anonym = observer(function () { });"], | ||
["const Arrow = () => { };", "const Arrow = observer(() => { });"], | ||
[ | ||
"class Cmp extends React.Component { }", | ||
"const Cmp = observer(class Cmp extends React.Component { })" | ||
], | ||
["class Cmp extends Component { }", "const Cmp = observer(class Cmp extends Component { })"], | ||
[ | ||
"const Cmp = class extends React.Component { }", | ||
"const Cmp = observer(class extends React.Component { })" | ||
], | ||
[ | ||
"const Cmp = class extends Component { }", | ||
"const Cmp = observer(class extends Component { })" | ||
], | ||
["class extends Component { }", "observer(class extends Component { })"], | ||
["class extends React.Component { }", "observer(class extends React.Component { })"] | ||
] | ||
|
||
tester.run("missing-observer", rule, { | ||
valid: valids.map(code => ({ code })), | ||
invalid: invalids.map(([code, output]) => ({ | ||
code, | ||
output, | ||
errors: [{ messageId: "missingObserver" }] | ||
})) | ||
}) |
39 changes: 39 additions & 0 deletions
39
packages/eslint-plugin-mobx/__tests__/no-anonymous-observer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { getRuleTester } from "./utils/get-rule-tester"; | ||
|
||
import rule from "../src/no-anonymous-observer.js" | ||
|
||
const tester = getRuleTester(); | ||
|
||
const valids = ["observer(function Name() {})", "observer(class Name {})"] | ||
|
||
const invalidsNotFixed = ["observer(() => {})", "observer(function () {})", "observer(class {})"] | ||
|
||
const invalidsFixed = [ | ||
["const Cmp = observer(() => {})", "const Cmp = observer(function Cmp() {})"], | ||
['const Cmp = observer(() => "")', 'const Cmp = observer(function Cmp() { return "" })'], | ||
[ | ||
"const Cmp = observer(() => expr())", | ||
"const Cmp = observer(function Cmp() { return expr() })" | ||
], | ||
[ | ||
"const Cmp = observer(() => literal)", | ||
"const Cmp = observer(function Cmp() { return literal })" | ||
], | ||
["const Cmp = observer(function () {})", "const Cmp = observer(function Cmp () {})"], | ||
["const Cmp = observer(class {})", "const Cmp = observer(class Cmp {})"] | ||
] | ||
|
||
tester.run("no-anonymous-observer", rule, { | ||
valid: valids.map(code => ({ code })), | ||
invalid: [ | ||
...invalidsNotFixed.map(code => ({ | ||
code, | ||
errors: [{ messageId: "observerComponentMustHaveName" }] | ||
})), | ||
...invalidsFixed.map(([code, output]) => ({ | ||
code, | ||
output, | ||
errors: [{ messageId: "observerComponentMustHaveName" }] | ||
})) | ||
] | ||
}) |
7 changes: 2 additions & 5 deletions
7
packages/eslint-plugin-mobx/__tests__/unconditional-make-observable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/eslint-plugin-mobx/__tests__/utils/get-rule-tester.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const version = global.ESLINT_V; | ||
|
||
const { RuleTester } = require(`eslint-${version}`); | ||
const typescriptEslintParser = require("@typescript-eslint/parser"); | ||
|
||
function getRuleTesterConfig() { | ||
switch (version) { | ||
case 7: | ||
return { | ||
parser: require.resolve("@typescript-eslint/parser"), | ||
parserOptions: {}, | ||
}; | ||
case 9: | ||
return { | ||
languageOptions: { | ||
parser: typescriptEslintParser, | ||
parserOptions: {}, | ||
}, | ||
}; | ||
default: | ||
throw new Error(`Unknown or unspecified ESLINT_V (${String(version)})`); | ||
} | ||
} | ||
|
||
function getRuleTester() { | ||
return new RuleTester(getRuleTesterConfig()); | ||
} | ||
|
||
export { getRuleTester } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const buildConfig = require("../../jest.base.config") | ||
|
||
module.exports = buildConfig(__dirname, { | ||
displayName: 'eslint-plugin-mobx with eslint@7', | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
testRegex: "__tests__/[^/]+\\.(t|j)sx?$", | ||
globals: { | ||
ESLINT_V: 7 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const buildConfig = require("../../jest.base.config") | ||
|
||
module.exports = buildConfig(__dirname, { | ||
displayName: 'eslint-plugin-mobx with eslint@9', | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
testRegex: "__tests__/[^/]+\\.(t|j)sx?$", | ||
globals: { | ||
ESLINT_V: 9 | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @see https://github.com/jsdom/jsdom/issues/3363 */ | ||
global.structuredClone = val => { | ||
return JSON.parse(JSON.stringify(val)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.