-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add should-be-fine support for flat configs (#343)
- Loading branch information
Showing
5 changed files
with
156 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('eslint-doc-generator').GenerateOptions} */ | ||
const config = { | ||
ignoreConfig: [ | ||
'all', | ||
'flat/all', | ||
'flat/recommended', | ||
], | ||
}; | ||
|
||
module.exports = config; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,81 @@ | ||
import { generateRecommendedConfig, rules } from "../"; | ||
import plugin, { configs, rules } from "../"; | ||
|
||
it("includes the configs and rules on the plugin", () => { | ||
expect(plugin).toHaveProperty("configs", configs); | ||
expect(plugin).toHaveProperty("rules", rules); | ||
}); | ||
|
||
it("should have all the rules", () => { | ||
expect(Object.keys(rules).length).toBeGreaterThan(0); | ||
expect(Object.keys(rules)).toHaveLength(11); | ||
}); | ||
|
||
it.each(Object.keys(rules))("%s should export required fields", (ruleName) => { | ||
const rule = rules[ruleName]; | ||
expect(rule).toHaveProperty("create", expect.any(Function)); | ||
expect(rule.meta.docs.url).not.toBe(""); | ||
expect(rule.meta.docs.category).toBe("Best Practices"); | ||
expect(rule.meta.docs.description).not.toBe(""); | ||
it.each(Object.entries(rules))( | ||
"%s should export required fields", | ||
(name, rule) => { | ||
expect(rule).toHaveProperty("create", expect.any(Function)); | ||
expect(rule.meta.docs.url).not.toBe(""); | ||
expect(rule.meta.docs.category).toBe("Best Practices"); | ||
expect(rule.meta.docs.description).not.toBe(""); | ||
} | ||
); | ||
|
||
it("has the expected recommended config", () => { | ||
expect(configs.recommended).toMatchInlineSnapshot(` | ||
Object { | ||
plugins: Array [ | ||
jest-dom, | ||
], | ||
rules: Object { | ||
jest-dom/prefer-checked: error, | ||
jest-dom/prefer-empty: error, | ||
jest-dom/prefer-enabled-disabled: error, | ||
jest-dom/prefer-focus: error, | ||
jest-dom/prefer-in-document: error, | ||
jest-dom/prefer-required: error, | ||
jest-dom/prefer-to-have-attribute: error, | ||
jest-dom/prefer-to-have-class: error, | ||
jest-dom/prefer-to-have-style: error, | ||
jest-dom/prefer-to-have-text-content: error, | ||
jest-dom/prefer-to-have-value: error, | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it("should have a recommended config with recommended rules", () => { | ||
expect( | ||
generateRecommendedConfig({ | ||
good: { meta: { docs: { recommended: true } } }, | ||
bad: { meta: { docs: { recommended: false } } }, | ||
}) | ||
).toEqual({ "jest-dom/good": "error" }); | ||
it("has the expected recommended flat config", () => { | ||
const expectJestDomPlugin = expect.objectContaining({ | ||
meta: { | ||
name: "eslint-plugin-jest-dom", | ||
version: expect.any(String), | ||
}, | ||
}); | ||
|
||
expect(configs["flat/recommended"]).toMatchInlineSnapshot( | ||
{ plugins: { "jest-dom": expectJestDomPlugin } }, | ||
` | ||
Object { | ||
plugins: Object { | ||
jest-dom: ObjectContaining { | ||
meta: Object { | ||
name: eslint-plugin-jest-dom, | ||
version: Any<String>, | ||
}, | ||
}, | ||
}, | ||
rules: Object { | ||
jest-dom/prefer-checked: error, | ||
jest-dom/prefer-empty: error, | ||
jest-dom/prefer-enabled-disabled: error, | ||
jest-dom/prefer-focus: error, | ||
jest-dom/prefer-in-document: error, | ||
jest-dom/prefer-required: error, | ||
jest-dom/prefer-to-have-attribute: error, | ||
jest-dom/prefer-to-have-class: error, | ||
jest-dom/prefer-to-have-style: error, | ||
jest-dom/prefer-to-have-text-content: error, | ||
jest-dom/prefer-to-have-value: error, | ||
}, | ||
} | ||
` | ||
); | ||
}); |
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