PageSourceSearch

https://rslint.rs/static/js/async/route-f70d24328176.bb795960c6.js

js rslint.rs collected 2026-10-05 08:01:54 UTC 17,115 bytes, 19 lines download raw bytes

1"use strict";(self.rspackChunk_rslint_website=self.rspackChunk_rslint_website||[]).push([[11226],{91261(e,s,r){r.r(s);var n=r(85511),i=r(2747),t=r(89388),o=r(52943);function l(e){let s={a:"a",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",span:"span",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s.h1,{id:"consistent-test-filename",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#consistent-test-filename",children:"#"}),"consistent-test-filename"]}),"\n",(0,n.jsx)(o.A,{introducedIn:"0.9.1"}),"\n",(0,n.jsxs)(s.h2,{id:"configuration",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#configuration",children:"#"}),"Configuration"]}),"\n",(0,n.jsxs)(s.table,{children:[(0,n.jsx)(s.thead,{children:(0,n.jsxs)(s.tr,{children:[(0,n.jsx)(s.th,{children:"Preset"}),(0,n.jsx)(s.th,{children:"Configured Value"})]})}),(0,n.jsx)(s.tbody,{children:(0,n.jsxs)(s.tr,{children:[(0,n.jsx)(s.td,{children:"✅ rstestPlugin.configs.all"}),(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:'"warn"'})})]})})]}),"\n",(0,n.jsx)(t.A,{name:"rstest/consistent-test-filename",group:"rstest"}),"\n",(0,n.jsxs)(s.h2,{id:"rule-details",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#rule-details",children:"#"}),"Rule Details"]}),"\n",(0,n.jsxs)(s.p,{children:["Requires every test file to be named according to a single convention. Rstest runs both ",(0,n.jsx)(s.code,{children:"*.test.*"})," and ",(0,n.jsx)(s.code,{children:"*.spec.*"})," files by default, so a project that mixes the two makes tests harder to locate and forces every coverage glob, CI shard, and editor filter to spell out both forms."]}),"\n",(0,n.jsxs)(s.p,{children:[(0,n.jsx)(s.code,{children:"allTestPattern"})," decides which files count as test files, and ",(0,n.jsx)(s.code,{children:"pattern"})," is the convention those files have to follow. Under the defaults a ",(0,n.jsx)(s.code,{children:"*.spec.*"})," file is a test file whose name does not match the required ",(0,n.jsx)(s.code,{children:"*.test.*"})," form, so it is reported. Both defaults accept the ",(0,n.jsx)(s.code,{children:".cts"}),", ",(0,n.jsx)(s.code,{children:".mts"}),", ",(0,n.jsx)(s.code,{children:".cjs"}),", and ",(0,n.jsx)(s.code,{children:".mjs"})," extensions that Rstest's ",(0,n.jsx)(s.a,{href:"https://rstest.rs/config/test/include",rel:"noopener noreferrer",target:"_blank",children:(0,n.jsx)(s.code,{children:"include"})})," glob accepts by default."]}),"\n",(0,n.jsxs)(s.p,{children:["Only the path is examined, never the contents. A file named ",(0,n.jsx)(s.code,{children:"*.spec.ts"})," is reported even when it registers no test, and a source file carrying ",(0,n.jsx)(s.a,{href:"https://rstest.rs/config/test/include-source",rel:"noopener noreferrer",target:"_blank",children:"in-source tests"})," is never reported, because its name is an ordinary source file's name. Both patterns are matched against the whole path rather than the basename, so a pattern such as ",(0,n.jsx)(s.code,{children:"__tests__"})," can select an entire directory. The diagnostic is reported at the start of the file."]}),"\n",(0,n.jsxs)(s.h2,{id:"incorrect",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#incorrect",children:"#"}),"Incorrect"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"ts",children:(0,n.jsxs)(s.code,{children:[(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-comment)"},children:"// user-service.spec.ts"})}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"test"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"("}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'creates a user'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" () "}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"  expect"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"("}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"createUser"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"({ name"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:" 'Ada'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" }))"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:".toMatchObject"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"({ name"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:" 'Ada'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" });"})]}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"});"})})]})})}),"\n",(0,n.jsxs)(s.h2,{id:"correct",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#correct",children:"#"}),"Correct"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"ts",children:(0,n.jsxs)(s.code,{children:[(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-comment)"},children:"// user-service.test.ts"})}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"test"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"("}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'creates a user'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" () "}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"  expect"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"("}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"createUser"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"({ name"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:" 'Ada'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" }))"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:".toMatchObject"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"({ name"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:" 'Ada'"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" });"})]}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"});"})})]})})}),"\n",(0,n.jsxs)(s.h2,{id:"options",children:[(0,n.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#options",children:"#"}),"Options"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"json",children:(0,n.jsxs)(s.code,{children:[(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"{"})}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'  "rstest/consistent-test-filename"'}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" ["})]}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'    "error"'}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"    {"})}),"\n",(0,n.jsxs)(s.span,{className:"line",children:[(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'      "pattern"'}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:' ".*\\\\.spec\\\\.(c|m)?[tj]sx?$"'})]}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"    }"})}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"  ]"})}),"\n",(0,n.jsx)(s.span,{className:"line",children:(0,n.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"}"})})]})})}),"\n",(0,n.jsxs)(s.table,{children:[(0,n.jsx)(s.thead,{children:(0,n.jsxs)(s.tr,{children:[(0,n.jsx)(s.th,{children:"Option"}),(0,n.jsx)(s.th,{children:"Type"}),(0,n.jsx)(s.th,{children:"Default"}),(0,n.jsx)(s.th,{children:"Description"})]})}),(0,n.jsxs)(s.tbody,{children:[(0,n.jsxs)(s.tr,{children:[(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:"pattern"})}),(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:"string"})}),(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:".*\\.test\\.(c|m)?[tj]sx?$"})}),(0,n.jsx)(s.td,{children:"Regular expression the path of a test file must match."})]}),(0,n.jsxs)(s.tr,{children:[(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:"allTestPattern"})}),(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:"string"})}),(0,n.jsx)(s.td,{children:(0,n.jsx)(s.code,{children:".*\\.(test|spec)\\.(c|m)?[tj]sx?$"})}),(0,n.jsx)(s.td,{children:"Regular expression selecting the paths the rule checks."})]})]})]})]})}function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,n.jsx)(s,{...e,children:(0,n.jsx)(l,{...e})}):l(e)}c.__RSPRESS_PAGE_META={},c.__RSPRESS_PAGE_META["en%2Frules%2Frstest%2Fconsistent-test-filename.mdx"]={toc:[{id:"configuration",text:"Configuration",depth:2},{id:"rule-details",text:"Rule Details",depth:2},{id:"incorrect",text:"Incorrect",depth:2},{id:"correct",text:"Correct",depth:2},{id:"options",text:"Options",depth:2}],title:"consistent-test-filename",headingTitle:"consistent-test-filename",frontmatter:{}},r.d(s,{default:()=>c})},89388(e,s,r){var n=r(85511);r(16255);var i=r(5906),t=r(56872);let o=Object.fromEntries(t.iy.filter(e=>e.presets.length>0).map(e=>[e.group,{importName:e.importName,preset:(e.presets.find(e=>e.name.endsWith(".configs.recommended"))??e.presets[0]).name}]));s.A=e=>{let{name:s,group:r}
1=e,l=o[r],c=t.iy.find(e=>e.group===r)?.prefix,a=l?`import { defineConfig, ${l.importName} } from '@rslint/core';
2
3export default defineConfig([
4  ${l.preset},
5  {
6    rules: {
7      '${s}': 'error',
8    },
9  },
10]);`:`import { defineConfig } from '@rslint/core';
11
12export default defineConfig([
13  {
14${c?`    plugins: ['${c}'],
15`:""}    rules: {
16      '${s}': 'error',
17    },
18  },
19]);`;return(0,n.jsx)(i.xZ,{lang:"ts",code:a,title:"rslint.config.ts"})}},52943(e,s,r){var n=r(85511);r(16255);var i=r(22046);s.A=e=>{let{introducedIn:s}=e;return s?(0,n.jsx)("a",{href:`https://github.com/web-infra-dev/rslint/releases/tag/v${s}`,target:"_blank",rel:"noreferrer",className:"group",title:`View the rslint v${s} release`,children:(0,n.jsxs)(i.E,{variant:"version",className:"underline-offset-2 group-hover:underline",children:["Added in v",s]})}):(0,n.jsx)(i.E,{variant:"unreleased",title:"This rule has not been assigned to an rslint release yet",children:"Unreleased"})}},22046(e,s,r){var n=r(85511);r(16255);var i=r(89924),t=r(70868);let o=(0,i.F)("inline-flex w-fit shrink-0 items-center justify-center rounded-xs px-2 py-1 text-xs font-medium whitespace-nowrap",{variants:{variant:{secondary:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300",version:"bg-emerald-200/80 text-black dark:bg-emerald-700/80 dark:text-white",unreleased:"bg-amber-100 text-black dark:bg-zinc-700 dark:text-white"}},defaultVariants:{variant:"secondary"}});function l(e){let{className:s,variant:r,...i}=e;return(0,n.jsx)("span",{"data-slot":"badge",className:(0,t.cn)(o({variant:r}),s),...i})}r.d(s,{E:()=>l})},70868(e,s,r){var n=r(23372),i=r(11212);function t(){for(var e=arguments.length,s=Array(e),r=0;r<e;r++)s[r]=arguments[r];return(0,i.QP)((0,n.$)(s))}r.d(s,{cn:()=>t})},56872(e,s,r){let n=[{prefix:"",group:"eslint",importName:"js",presets:[{name:"js.configs.recommended",description:"JavaScript recommended rules"}]},{prefix:"@typescript-eslint",group:"@typescript-eslint",importName:"ts",presets:[{name:"ts.configs.recommended",description:"TypeScript recommended rules"},{name:"ts.configs.recommendedTypeChecked",description:"TypeScript recommended rules, including typed ones"},{name:"ts.configs.strict",description:"TypeScript recommended rules plus opinionated extras"},{name:"ts.configs.strictTypeChecked",description:"TypeScript strict rules, including typed ones"},{name:"ts.configs.stylistic",description:"TypeScript consistency rules"},{name:"ts.configs.stylisticTypeChecked",description:"TypeScript consistency rules, including typed ones"}]},{prefix:"react",group:"eslint-plugin-react",importName:"reactPlugin",presets:[{name:"reactPlugin.configs.recommended",description:"React rules"}]},{prefix:"react-hooks",group:"eslint-plugin-react-hooks",importName:"reactHooksPlugin",presets:[{name:"reactHooksPlugin.configs.recommended",description:"React Hooks rules"}]},{prefix:"import",group:"eslint-plugin-import",importName:"importPlugin",presets:[{name:"importPlugin.configs.recommended",description:"Import/export rules"}]},{prefix:"node",group:"eslint-plugin-node",importName:"nodePlugin",presets:[{name:"nodePlugin.configs.recommended",description:"Node.js rules for mixed CommonJS and ES modules"},{name:"nodePlugin.configs.recommendedModule",description:"Node.js rules for ES modules"},{name:"nodePlugin.configs.recommendedScript",description:"Node.js rules for CommonJS"}]},{prefix:"promise",group:"eslint-plugin-promise",importName:"promisePlugin",presets:[{name:"promisePlugin.configs.recommended",description:"Promise rules"}]},{prefix:"jest",group:"eslint-plugin-jest",importName:"jestPlugin",presets:[{name:"jestPlugin.configs.all",description:"All supported Jest rules"},{name:"jestPlugin.configs.recommended",description:"Jest rules"},{name:"jestPlugin.configs.style",description:"Jest style rules"}]},{prefix:"rstest",group:"rstest",importName:"rstestPlugin",presets:[{name:"rstestPlugin.configs.all",description:"All supported Rstest rules"},{name:"rstestPlugin.configs.env",description:"Rstest globals"},{name:"rstestPlugin.configs.recommended",description:"Rstest rules"},{name:"rstestPlugin.configs.style",description:"Rstest style rules"}]},{prefix:"unicorn",group:"eslint-plugin-unicorn",importName:"unicornPlugin",presets:[{name:"unicornPlugin.configs.recommended",description:"Unicorn rules"}]},{prefix:"jsx-a11y",group:"eslint-plugin-jsx-a11y",importName:"jsxA11yPlugin",presets:[{name:"jsxA11yPlugin.configs.recommended",description:"JSX a11y rules"}]}];function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n;return e.flatMap(e=>e.presets.map(s=>({...e,...s})))}function t(e){let s=n.find(s=>s.group===e);return(s?.prefix||e).replace(/^@/,"")}r.d(s,{IM:()=>i,RK:()=>t},{iy:n})},89924(e,s,r){var n=r(23372);let i=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,t=n.$;r.d(s,{},{F:(e,s)=>r=>{var n;if((null==s?void 0:s.variants)==null)return t(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:o,defaultVariants:l}=s,c=Object.keys(o).map(e=>{let s=null==r?void 0:r[e],n=null==l?void 0:l[e];
19if(null===s)return null;let t=i(s)||i(n);return o[e][t]}),a=r&&Object.entries(r).reduce((e,s)=>{let[r,n]=s;return void 0===n||(e[r]=n),e},{});return t(e,c,null==s||null==(n=s.compoundVariants)?void 0:n.reduce((e,s)=>{let{class:r,className:n,...i}=s;return Object.entries(i).every(e=>{let[s,r]=e;return Array.isArray(r)?r.includes({...l,...a}[s]):({...l,...a})[s]===r})?[...e,r,n]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.