Skip to content

Commit

Permalink
[ESLint Plugin] Updates no-document-import-in-page rule to use `pat…
Browse files Browse the repository at this point in the history
  • Loading branch information
housseindjirdeh committed Sep 3, 2021
1 parent 1d08172 commit d056312
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path')

module.exports = {
meta: {
docs: {
Expand All @@ -18,8 +20,8 @@ module.exports = {

if (
!page ||
page.startsWith('/_document') ||
page.startsWith('\\_document')
page.startsWith(`${path.sep}_document`) ||
page.startsWith(`${path.posix.sep}_document`)
) {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path'

import rule from '@next/eslint-plugin-next/lib/rules/no-document-import-in-page'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
Expand Down Expand Up @@ -40,7 +42,7 @@ ruleTester.run('no-document-import-in-page', rule, {
}
}
`,
filename: 'pages\\_document.js',
filename: `pages${path.sep}_document.js`,
},
{
code: `import NextDocument from "next/document"
Expand All @@ -54,7 +56,7 @@ ruleTester.run('no-document-import-in-page', rule, {
}
}
`,
filename: 'pages/_document.tsx',
filename: `pages${path.posix.sep}_document.tsx`,
},
{
code: `import Document from "next/document"
Expand Down Expand Up @@ -147,7 +149,7 @@ ruleTester.run('no-document-import-in-page', rule, {
export const Test = () => <p>Test</p>
`,
filename: 'pages\\test.js',
filename: `pages${path.sep}test.js`,
errors: [
{
message:
Expand Down

0 comments on commit d056312

Please sign in to comment.