Skip to content

Commit eded332

Browse files
author
Josh Wilson
committed
Tested and fixed importing/using recommended config.
1 parent 7c28cbc commit eded332

File tree

7 files changed

+75
-10
lines changed

7 files changed

+75
-10
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
2-
node_modules
2+
node_modules
3+
/test/fixture

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"prepare": "husky install",
1515
"docs": "PARSER=none ts-node --transpile-only scripts/docs.ts",
1616
"build": "tsc -p tsconfig.build.json && yarn run docs",
17-
"test": "mocha -r ts-node/register --extension=ts test/**/*.test.ts",
17+
"test": "mocha -r ts-node/register --extension=ts 'test/**/*.test.ts'",
1818
"test:ts": "PARSER=ts yarn test",
1919
"test:babel": "PARSER=babel yarn test",
2020
"test:v6": "PARSER=v6 yarn test",
@@ -39,7 +39,7 @@
3939
"@types/eslint": "^7.2.13",
4040
"@types/estree": "^0.0.50",
4141
"@types/estree-jsx": "^0.0.1",
42-
"@types/mocha": "^8.2.3",
42+
"@types/mocha": "^9.0.0",
4343
"@types/node": "^16.4.0",
4444
"@typescript-eslint/eslint-plugin": "^4.28.2",
4545
"@typescript-eslint/parser": "^4.28.2",
@@ -59,7 +59,7 @@
5959
"eslint": "6.x-7.x"
6060
},
6161
"lint-staged": {
62-
"*.{js,ts}": [
62+
"*.ts": [
6363
"eslint --fix",
6464
"prettier --write"
6565
]

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ const allRules = {
2424
"style-prop": styleProp,
2525
};
2626

27-
export default {
27+
// Must be module.exports for eslint to load everything
28+
module.exports = {
2829
rules: allRules,
2930
configs: {
3031
recommended: {
31-
plugins: "solid",
32+
plugins: ["solid"],
33+
env: {
34+
browser: true,
35+
es6: true,
36+
},
3237
parserOptions: {
38+
ecmaVersion: 6,
3339
ecmaFeatures: {
3440
jsx: true,
41+
impliedStrict: true,
3542
},
3643
},
3744
rules: {

test/fixture.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import execa from "execa";
2+
import path from "path";
3+
import assert from "assert";
4+
import fs from "fs/promises";
5+
6+
const nodeModulesFileForTesting = path.resolve(
7+
__dirname,
8+
"..",
9+
"node_modules",
10+
"eslint-plugin-solid.js"
11+
);
12+
13+
const fixtureCwd = path.resolve(__dirname, "fixture");
14+
15+
// We can't use `yarn bin` because it uses the eslint-v6 bin
16+
const eslintPath = require.resolve("eslint/bin/eslint.js");
17+
18+
describe("fixture", function () {
19+
this.slow(500);
20+
21+
before(async () => {
22+
// We're trying to require the package we're currently in; we can work around
23+
// this by putting a skeleton file inside `node_modules` that requires the top
24+
// level directory.
25+
await fs.writeFile(nodeModulesFileForTesting, `module.exports = require("..");\n`);
26+
});
27+
28+
after(async () => {
29+
await fs.unlink(nodeModulesFileForTesting);
30+
});
31+
32+
it("loads the plugin without crashing", async () => {
33+
const { exitCode } = await execa.node(eslintPath, ["--print-config", "super-simple.js"], {
34+
cwd: fixtureCwd,
35+
});
36+
assert.strictEqual(exitCode, 0);
37+
});
38+
39+
it("produces reasonable lint errors", async () => {
40+
try {
41+
await execa.node(eslintPath, ["super-simple.js"], {
42+
cwd: fixtureCwd,
43+
});
44+
} catch (error) {
45+
assert.strictEqual(error.exitCode, 1);
46+
assert.match(error.stdout, /'Component' is not defined/);
47+
assert.match(error.stdout, /solid\/jsx-no-undef/);
48+
assert.match(error.stdout, /1 problem \(1 error, 0 warnings\)/);
49+
}
50+
});
51+
});

test/fixture/.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"root": true,
3+
"extends": "plugin:solid/recommended",
4+
"plugins": ["solid"]
5+
}

test/fixture/super-simple.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let el = <Component />;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@
397397
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
398398
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==
399399

400-
"@types/mocha@^8.2.3":
401-
version "8.2.3"
402-
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.3.tgz#bbeb55fbc73f28ea6de601fbfa4613f58d785323"
403-
integrity sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==
400+
"@types/mocha@^9.0.0":
401+
version "9.0.0"
402+
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297"
403+
integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==
404404

405405
"@types/node@*":
406406
version "16.4.10"

0 commit comments

Comments
 (0)