dukeluo / eslint-plugin-check-file

ESLint rules for consistent filename and folder. Allows you to enforce a consistent naming pattern for the filename and folder.

Home Page:https://www.npmjs.com/package/eslint-plugin-check-file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

folder rule: reported multiple times (once per containing file)

fauxbytes opened this issue · comments

I've setup this proj: a folder with an invalid name contains two files. When linting, the folder is reported twice as not matching its rule.

$ find src/
src/
src/Bar
src/Bar/a.ts
src/Bar/b.ts
$ cat .eslintrc.yml
env:
  es2021: true
  node: true
overrides: [ ]
parser: '@typescript-eslint/parser'
parserOptions:
  ecmaVersion: latest
  sourceType: module
plugins:
  - 'check-file'
rules: {
  'check-file/folder-naming-convention': [ 'warn', { 'src/**': 'KEBAB_CASE' } ],
}
$ cat package.json
{
  "name": "bar",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\""
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@typescript-eslint/parser": "^5.59.11",
    "eslint": "^8.42.0",
    "eslint-plugin-check-file": "^2.4.0",
    "typescript": "^4.9.3",
    "typescript-eslint": "^0.0.1-alpha.0"
  }
}
$ npm run lint

> bar@1.0.0 lint
> eslint "{src,apps,libs,test}/**/*.ts"


C:\Users\amitd\AppData\Local\Temp\bar\src\Bar\a.ts
  1:1  warning  The folder "Bar" does not match the "KEBAB_CASE" pattern  check-file/folder-naming-convention

C:\Users\amitd\AppData\Local\Temp\bar\src\Bar\b.ts
  1:1  warning  The folder "Bar" does not match the "KEBAB_CASE" pattern  check-file/folder-naming-convention

✖ 2 problems (0 errors, 2 warnings)
commented

@fauxbytes It appears that the issue you mentioned is not a bug. Please allow me to clarify that ESLint operates on a file-by-file basis rather than analyzing entire folders. In the case you provided, both files have a folder in their path that does not match the naming convention, resulting in two similar errors. Based on this behavior, it seems that ESLint is functioning as intended. If you have any further questions or concerns, please let me know.