Unverified Commit 82682a3a authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Disable head element lint rule for appDir (#40921)

Only lint `<head>` elements usage in `pages/`, `<head>` should be able
to use in appDir
parent 3837aa1c
......@@ -14,7 +14,11 @@ module.exports = {
create: function (context) {
return {
JSXOpeningElement(node) {
if (node.name.name !== 'head') {
const paths = context.getFilename()
const isInAppDir = paths.includes('app/') && !paths.includes('pages/')
// Only lint the <head> element in pages directory
if (node.name.name !== 'head' || isInAppDir) {
return
}
......
......@@ -48,6 +48,21 @@ ruleTester.run('no-head-element', rule, {
`,
filename: 'pages/index.tsx',
},
{
code: `
export default function Layout({ children }) {
return (
<html>
<head>
<title>layout</title>
</head>
<body>{children}</body>
</html>
);
}
`,
filename: './app/layout.js',
},
],
invalid: [
{
......@@ -63,7 +78,7 @@ ruleTester.run('no-head-element', rule, {
);
}
}`,
filename: 'pages/index.js',
filename: './pages/index.js',
errors: [
{
message:
......
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