简体   繁体   中英

Enforce file naming convention with typescript-eslint

I want to automatically enforce file naming conventions for my typescript + react codebase.

eg all .ts filenames have to be camelCase all .tsx filenames have to be PascalCase

Orelsanpls has referenced typescript-eslint doing that, however I can only find the naming-conventions rules for variables, classes, members etc.

TSLint contained file-name-casing rules, which is exactly what I'm looking for in typescript-eslint .

Am I missing something about naming-conventions in typescript-eslint ?

The only supported plugin I could find today doing so is eslint-plugin-unicorn you can see the reference to the rule that can help you here: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md

You might want to only enable this rule as the plugin comes with many other opinionated rules that you might or might not agree with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM