Unverified Commit 0833f83c authored by stefanprobst's avatar stefanprobst Committed by GitHub

Fix eslint config next/core-web-vitals (#27567)

fixes what i messed up in #27363. cf. https://github.com/vercel/next.js/pull/27363#issuecomment-888495697

also added an integration test for extending from `next/core-web-vitals` eslint config

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
parent c7e2a1df
module.exports = {
extends: ['.', 'plugin:@next/next/core-web-vitals'].map(require.resolve),
extends: [require.resolve('.'), 'plugin:@next/next/core-web-vitals'],
}
{
"extends": "next/core-web-vitals",
"root": true
}
const Home = () => (
<div>
<p>Home</p>
<script src="https://example.com" />
<img src="https://example.com/image.png" />
</div>
)
export default Home
......@@ -8,6 +8,7 @@ jest.setTimeout(1000 * 60 * 2)
const dirFirstTimeSetup = join(__dirname, '../first-time-setup')
const dirCustomConfig = join(__dirname, '../custom-config')
const dirWebVitalsConfig = join(__dirname, '../config-core-web-vitals')
const dirPluginRecommendedConfig = join(
__dirname,
'../plugin-recommended-config'
......@@ -167,6 +168,21 @@ describe('ESLint', () => {
)
})
test('shows warnings and errors with next/core-web-vitals config', async () => {
const { stdout, stderr } = await nextLint(dirWebVitalsConfig, [], {
stdout: true,
stderr: true,
})
const output = stdout + stderr
expect(output).toContain(
"Warning: Do not use <img>. Use Image from 'next/image' instead."
)
expect(output).toContain(
'Error: External synchronous scripts are forbidden'
)
})
test('shows warnings and errors when extending plugin recommended config', async () => {
const { stdout, stderr } = await nextLint(
dirPluginRecommendedConfig,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment