Download next.js/test/unit/eslint-plugin-next/no-typos.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.6 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/eslint-plugin-next/no-typos.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/unit/eslint-plugin-next/no-typos.test.ts
-
curl -L -o no-typos.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/eslint-plugin-next/no-typos.test.ts
3.6 kB
| import { RuleTester as ESLintTesterV8 } from 'eslint-v8' | |
| import { RuleTester as ESLintTesterV9 } from 'eslint' | |
| import { rules } from '@next/eslint-plugin-next' | |
| const NextESLintRule = rules['no-typos'] | |
| const tests = { | |
| valid: [ | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export const getStaticPaths = async () => {}; | |
| export const getStaticProps = async () => {}; | |
| `, | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export const getServerSideProps = async () => {}; | |
| `, | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getStaticPaths() {}; | |
| export async function getStaticProps() {}; | |
| `, | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getServerSideProps() {}; | |
| `, | |
| // detect only typo that is one operation away from the correct one | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getServerSidePropsss() {}; | |
| `, | |
| ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getstatisPath() {}; | |
| `, | |
| ], | |
| invalid: [ | |
| { | |
| code: ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export const getStaticpaths = async () => {}; | |
| export const getStaticProps = async () => {}; | |
| `, | |
| filename: 'pages/index.js', | |
| errors: [ | |
| { | |
| message: 'getStaticpaths may be a typo. Did you mean getStaticPaths?', | |
| type: 'ExportNamedDeclaration', | |
| }, | |
| ], | |
| }, | |
| { | |
| code: ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getStaticPathss(){}; | |
| export async function getStaticPropss(){}; | |
| `, | |
| filename: 'pages/index.js', | |
| errors: [ | |
| { | |
| message: | |
| 'getStaticPathss may be a typo. Did you mean getStaticPaths?', | |
| type: 'ExportNamedDeclaration', | |
| }, | |
| { | |
| message: | |
| 'getStaticPropss may be a typo. Did you mean getStaticProps?', | |
| type: 'ExportNamedDeclaration', | |
| }, | |
| ], | |
| }, | |
| { | |
| code: ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export async function getServurSideProps(){}; | |
| `, | |
| filename: 'pages/index.js', | |
| errors: [ | |
| { | |
| message: | |
| 'getServurSideProps may be a typo. Did you mean getServerSideProps?', | |
| type: 'ExportNamedDeclaration', | |
| }, | |
| ], | |
| }, | |
| { | |
| code: ` | |
| export default function Page() { | |
| return <div></div>; | |
| } | |
| export const getServurSideProps = () => {}; | |
| `, | |
| filename: 'pages/index.js', | |
| errors: [ | |
| { | |
| message: | |
| 'getServurSideProps may be a typo. Did you mean getServerSideProps?', | |
| type: 'ExportNamedDeclaration', | |
| }, | |
| ], | |
| }, | |
| ], | |
| } | |
| describe('no-typos', () => { | |
| new ESLintTesterV8({ | |
| parserOptions: { | |
| ecmaVersion: 2018, | |
| sourceType: 'module', | |
| ecmaFeatures: { | |
| modules: true, | |
| jsx: true, | |
| }, | |
| }, | |
| }).run('eslint-v8', NextESLintRule, tests) | |
| new ESLintTesterV9({ | |
| languageOptions: { | |
| ecmaVersion: 2018, | |
| sourceType: 'module', | |
| parserOptions: { | |
| ecmaFeatures: { | |
| modules: true, | |
| jsx: true, | |
| }, | |
| }, | |
| }, | |
| }).run('eslint-v9', NextESLintRule, tests) | |
| }) | |