린팅 구성

기본 린팅 설정과 의도된 동작 방식 사이에 상당한 차이를 발견했습니다.

기본 설정은 eslint-config-discourse 패키지를 dev devendency로 설치합니다:

https://www.npmjs.com/package/eslint-config-discourse

하지만 https://github.com/discourse/eslint-config-discourse 에서 소스 코드를 찾아보면, 해당 저장소가 @discourse/lint-configs로 리다이렉트됩니다. 이는 eslint-config-discourse 모노레포 하위의 또 다른 패키지이기도 합니다. 포함된 테스트를 보면 eslint-config-discourse가 래퍼(wrapper) 역할을 해야 한다고 생각하는데, 제 경험상 의도된 대로 작동하지 않습니다:

기본 린팅 설정

  1. discourse_theme new 명령을 사용하여 새 테마를 생성합니다.
  2. 생성된 린팅 구성을 검토합니다:
    a. .eslintrc
    {
      "extends": "eslint-config-discourse",
      "globals": {
        "settings": "readonly",
        "themePrefix": "readonly"
      }
    }
    
    b. .template-lintrc.js:
    module.exports = {
      plugins: ["ember-template-lint-plugin-discourse"],
      extends: "discourse:recommended",
    };
    
    c. package.json
    {
      "license": "MIT",
      "devDependencies": {
        "eslint-config-discourse": "latest"
      }
    }
    
  3. 패키지에 Prettier를 실행하면 *.gjs 파일에 대해 오류가 발생합니다:
    yarn prettier --check --write "{common,javascripts,desktop,mobile,test,scss}/**/*.{js,gjs,es6,scss}"
    
    Error: No parser could be inferred for file ... .gjs

@discourse/lint-configs 직접 구성

https://www.npmjs.com/package/@discourse/lint-configs

  1. yarn remove -D eslint-config-discourse를 실행하여 패키지를 제거합니다.
  2. yarn add -D @discourse/lint-configs를 실행하여 dev dependency로 설치합니다.
  3. 지침에 따라 린팅 구성 파일을 생성합니다:
    a. .eslintrc 파일을 .eslintrc.cjs로 교체합니다.
    module.exports = require("@discourse/lint-configs/eslint-theme");
    
    b. .prettierrc.cjs 파일을 추가합니다:
    module.exports = require("@discourse/lint-configs/prettier");
    
    c. .template-lintrc.js 파일을 .template-lintrc.cjs로 교체합니다:
    module.exports = require("@discourse/lint-configs/template-lint");
    
  4. Prettier를 다시 실행하여 오류 없이 작동하는지 확인합니다:
    $ yarn prettier --check --write "{common,javascripts,desktop,mobile,test,scss}/**/*.{js,gjs,es6,scss}"
    Checking formatting...
    All matched files use Prettier code style!
    ✨  Done in 0.46s.
    

따라서 discourse_theme CLI가 구식(outdated)이며, 앞으로 프로젝트에서 @discourse/lint-configs 옵션을 사용해야 한다고 가정해도 될까요?

아니요. 그 점을 믿으세요. 자신의 저장소에 커밋을 제출하고, linting 명령이 실패할 때 어떤 출력이 나오는지 확인해 보세요.

@pfaffman 님,

저장소에서 작은 테스트를 해 보았습니다. 두 경우 모두 완료(completion)는 통과하지만, 기본 설정에서는 GJS 파일에 대해 오류가 발생하며 스캔되지 않습니다.

두 번째 접근 방식을 사용하면 GJS 파일이 인식되고 성공적으로 린팅됩니다.

main 브랜치의 액션과 linting 브랜치의 액션을 비교해 주세요. linting 브랜치에는 두 번째 옵션의 설정만 도입했습니다:

main:
https://github.com/gormus/discourse-filtered-topic-lists/actions/runs/10325377606/job/28586838134?pr=1#step:6:19

linting:
https://github.com/gormus/discourse-filtered-topic-lists/actions/runs/10333473217/job/28605865585?pr=3#step:6:17

그렇게 하지 않아야 합니다. 최신 버전의 discourse_theme CLI는 https://github.com/discourse/discourse-theme-skeleton을 클론한 후, 입력값에 따라 이를 조정합니다. 이 과정에서 @discourse/lint-configs가 사용됩니다.

업데이트 지침은 여기에 있습니다:

감사합니다. 그게 문제였네요. 이제 버전을 확인할 수 있습니다(이전에는 버전이 표시되지 않았습니다):

discourse_theme --version
2.1.2

…그리고 업데이트된 명령어 목록도 확인했습니다:

discourse_theme --help
Usage: discourse_theme COMMAND [DIR] [OPTIONS]

Commands:
  new DIR               - Creates a new theme in the specified directory.
  download DIR          - Downloads a theme from the server and stores it in the specified directory.
  upload DIR            - Uploads the theme from the specified directory to Discourse.
  watch DIR             - Watches the theme in the specified directory and synchronizes any changes with Discourse.
  rspec DIR [OPTIONS]   - Runs the RSpec tests in the specified directory. The tests can be run using a local Discourse repository or a Docker container.
    --headful           - Runs the RSpec system type tests in headful mode. Applies to both modes.

    If specified directory has been configured to run in a Docker container, the additional options are supported.
    --rebuild           - Forces a rebuilds of Docker container.
    --verbose           - Runs the command to prepare the Docker container in verbose mode.

Global Options:
  --reset               - Resets the configuration for the specified directory.

물론 생성된 스켈레톤도 더 최신 버전입니다. :smiley: