-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds tests to ensure eslint-plugin-next
's available rules are properly exported and recommended rules are correctly defined.
#38183
Merged
ijjk
merged 5 commits into
vercel:canary
from
manovotny:add-eslint-plugin-next-index-tests
Jun 30, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6d0e9ae
Adds tests to ensure `eslint-plugin-next`'s available rules are prope…
manovotny ef98f93
Condenses imports.
manovotny 0a95889
Sets default recommended value.
manovotny e5c17b3
replace Object.hasOwn for node 14
ijjk 6716ece
Merge branch 'canary' into add-eslint-plugin-next-index-tests
ijjk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import * as matchers from 'jest-extended' | ||
expect.extend(matchers) | ||
|
||
// A default max-timeout of 90 seconds is allowed | ||
// per test we should aim to bring this down though | ||
jest.setTimeout((process.platform === 'win32' ? 180 : 90) * 1000) |
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 @@ | ||
import 'jest-extended' |
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,28 @@ | ||
import { basename } from 'path' | ||
import glob from 'glob' | ||
import index from '@next/eslint-plugin-next' | ||
|
||
const getRuleNameFromRulePath = (path) => basename(path, '.js') | ||
const rulePaths = glob.sync('packages/eslint-plugin-next/lib/rules/*js', { | ||
absolute: true, | ||
}) | ||
|
||
describe('@next/eslint-plugin-next index', () => { | ||
it('should include all defined rules and no extra / undefined rules', () => { | ||
const rules = rulePaths.map((rulePath) => getRuleNameFromRulePath(rulePath)) | ||
|
||
expect(index.rules).toContainAllKeys(rules) | ||
}) | ||
|
||
rulePaths.forEach((rulePath) => { | ||
const rule = require(rulePath) | ||
const ruleName = getRuleNameFromRulePath(rulePath) | ||
const { recommended = false } = rule.meta.docs | ||
|
||
it(`${ruleName}: recommend should be \`${recommended}\``, () => { | ||
expect(`@next/next/${ruleName}` in index.configs.recommended.rules).toBe( | ||
recommended | ||
) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
} | ||
}, | ||
"include": [ | ||
"test/jest.d.ts", | ||
"test/**/*.test.ts", | ||
"test/**/*.test.tsx", | ||
"test/**/test/*", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ijjk good thinking! 👍