🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis β†’
Socket
Book a DemoInstallSign in
Socket

@lintest/cli

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lintest/cli

Integrated lint and test environment project

Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
Β 
Created
Source

Lintest CLI

npm node types downloads license

Copyright 2020. mornya. All rights reserved.

About

Integrated lint and test environment project.

Features

  • TypeScript / ES6+ support with TypeScript.
  • Linting TypeScript / JavaScript codes with ESLint.
  • Testing codes with Jest.
  • All available for Node.js / React.js / Vue.js (Nuxt.js) application

Installation

ν•΄λ‹Ή λΌμ΄λΈŒλŸ¬λ¦¬λŠ” κΈ€λ‘œλ²Œ μ˜μ—­μ— μ„€μΉ˜ν•œλ‹€.

npm λŒ€μ‹  yarn μ‚¬μš©μ‹œ, ν”„λ‘œμ νŠΈ 루트 κ²½λ‘œμ— package-lock.json 파일이 μ‘΄μž¬ν•˜λ©΄ μ œκ±°ν•˜κ³  yarn.lock 파일만 μ°Έμ‘°λ˜λ„λ‘ ν•œλ‹€.

$ npm install -g @lintest/cli
or
$ yarn global add @lintest/cli

Execution

Commands

$ lintest [commands] [args...]

μ‚¬μš©κ°€λŠ₯ν•œ commandsλŠ” μ•„λž˜μ™€ κ°™λ‹€.

  • export: 린트 및 ν…ŒμŠ€νŠΈ ν™˜κ²½μ„€μ • λ‚΄μš©μ„ JSON 파일둜 좜λ ₯
  • install: 린트 λ£° λ””νŽœλ˜μ‹œ μ„€μΉ˜ 및 lintest 정보 생성, λͺ¨λ“ˆ μ—…κ·Έλ ˆμ΄λ“œ
  • lint: ν”„λ‘œμ νŠΈ λ‚΄ μ½”λ“œμ— λŒ€ν•œ 린트 μˆ˜ν–‰
  • test: ν”„λ‘œμ νŠΈ λ‚΄ ν…ŒμŠ€νŠΈ μ½”λ“œμ— λŒ€ν•œ ν…ŒμŠ€νŠΈμΌ€μ΄μŠ€ μˆ˜ν–‰
  • uninstall: μƒμ„±λœ 정보 및 λ³΅μ‚¬λœ 파일 λ“± install/export μˆ˜ν–‰μ— λ”°λ₯Έ κ΄€λ ¨ 파일 제거

CLI

lintest ν™˜κ²½μ„€μ •μ€ ν”„λ‘œμ νŠΈ 루트 경둜 ν˜Ήμ€ ν™ˆ 디렉토리에 lintest.config.js 파일둜 μƒμ„±ν•˜λ©΄ λœλ‹€. ν•΄λ‹Ή 파일이 μ‘΄μž¬ν•˜λ©΄ lintest install λͺ…λ Ή μˆ˜ν–‰μ‹œ providerν•­λͺ©μœΌλ‘œ μ§€μ •λœ λ””νŽœλ˜μ‹œκ°€ ν”„λ‘œμ νŠΈμ— μ„€μΉ˜λ˜λ©°, 린트 룰은 ν•΄λ‹Ή λ””νŽœλ˜μ‹œ 섀정에 λ”°λ₯΄κ²Œ λœλ‹€.

lintest.config.js 파일이 ν”„λ‘œμ νŠΈ λ£¨νŠΈμ— μ‘΄μž¬ν•˜μ§€ μ•ŠμœΌλ©΄ ν™ˆ λ””λ ‰ν† λ¦¬μ—μ„œ μ°Ύκ³ , μ—†λ‹€λ©΄ ν”„λ‘œμ νŠΈ μƒμœ„, μ°¨μƒμœ„ κ²½λ‘œμ—μ„œ μ°ΎλŠ”λ‹€.

// lintest.config.js
module.exports = {
  provider: 'sample',
}

μœ„μ™€ 같이 μ„€μ •ν•˜λ©΄ lintest install λͺ…λ Ή μ‹€ν–‰μ‹œ @lintest/rules-sample λ””νŽœλ˜μ‹œκ°€ ν”„λ‘œμ νŠΈ λ‚΄ μ„€μΉ˜κ°€ 되며 lint rule은 ν•΄λ‹Ή λ””νŽœλ˜μ‹œ λ‚΄ 섀정을 λ”°λ₯Έλ‹€.

rules λ””νŽœλ˜μ‹œ 생성은 μ•„λž˜μ—μ„œ 닀룬닀.

린트 및 ν…ŒμŠ€νŠΈ μˆ˜ν–‰μ€ CLI둜 μ‹€ν–‰ν•˜λ©°, μ»€λ§¨λ“œλΌμΈμ—μ„œ μ•„λž˜μ™€ 같이 μ‹€ν–‰ ν•  수 μžˆλ‹€.

# 린트 μ‹€ν–‰μ‹œ
$ lintest lint [fix][debug][nocache]

# ν…ŒμŠ€νŠΈ μ‹€ν–‰μ‹œ
$ lintest test [watch][coverage][nocache]

린트 및 ν…ŒμŠ€νŠΈ ν™˜κ²½μ„€μ • λ‚΄μš©μ΄ ν•„μš”ν•  경우 export λͺ…령을 μ‚¬μš©ν•˜μ—¬ ν™˜κ²½μ„€μ •μ„ μ°Έκ³ ν•  수 μžˆλ‹€.
μˆ˜ν–‰κ²°κ³ΌλŠ” ν”„λ‘œμ νŠΈ 루트 κ²½λ‘œμ— eslint.config.json 및 jest.config.json 파일이 μƒμ„±λœλ‹€.
λ§Œμ•½ 정상적인 좜λ ₯이 λ˜μ§€ μ•ŠλŠ”λ‹€λ©΄ debug νŒŒλΌλ―Έν„°λ‘œ ν™•μΈν•œλ‹€.

$ lintest export [debug]

NPM

NPM ν”„λ‘œμ νŠΈμ—μ„œλŠ” npm run λͺ…λ ΉμœΌλ‘œ μ‹€ν–‰λ˜λ„λ‘ μ•„λž˜μ™€ 같이 package.json 파일 내에 μ„€μ •ν•œλ‹€.

{
  "scripts": {
    "lint": "lintest lint",
    "lint:fix": "lintest lint fix",
    "lint:debug": "lintest lint debug nocache",
    "test": "lintest test",
    "test:watch": "lintest test watch",
    "test:coverage": "lintest test coverage nocache"
  }
}

ν”„λ‘œμ νŠΈ npm install 후에 lintest μ—…λ°μ΄νŠΈ 및 λ£° μ—…λ°μ΄νŠΈλ₯Ό μžλ™μœΌλ‘œ μˆ˜ν–‰ν•΄ 쀄 수 μžˆλ„λ‘ μ•„λž˜μ™€ 같이 섀정해도 μ’‹λ‹€.

exit 0은 lintestκ°€ μ„€μΉ˜λ˜μ–΄ μžˆμ§€ μ•Šμ„ 경우, 였λ₯˜λ‘œ 인해 λ‹€μŒ ν”„λ‘œμ„ΈμŠ€κ°€ λ™μž‘ν•˜μ§€ μ•ŠλŠ” 것을 λ°©μ§€ν•˜κΈ° μœ„ν•΄ μ •μƒμ’…λ£Œλ‘œ μ²˜λ¦¬ν•˜λ„λ‘ ν•΄μ€€λ‹€.

{
  "scripts": {
    "postinstall": "lintest install || exit 0",
    "postuninstall": "lintest install || exit 0"
  }
}

Testing

ν…ŒμŠ€νŠΈμΌ€μ΄μŠ€λ₯Ό μˆ˜ν–‰ν•˜κΈ° μœ„ν•΄ CLI의 λ””νŽœλ˜μ‹œλ‘œ μ„€μΉ˜λœ jest λ°”μ΄λ„ˆλ¦¬κ°€ μ‹€ν–‰λœλ‹€.
ν…ŒμŠ€νŠΈ νŒŒμΌμ€ ν”„λ‘œμ νŠΈ λ‚΄ μ‘΄μž¬ν•˜λŠ” *.test.{ts|tsx|js|jsx} νŒŒμΌλ“€μ΄ ν…ŒμŠ€νŠΈ λŒ€μƒμ΄ λœλ‹€.

Setup files

각 λ‹¨μœ„ ν…ŒμŠ€νŠΈλ₯Ό μˆ˜ν–‰ν•˜κΈ° μ „ mocking methodλ‚˜ 초기 섀정을 ν•  수 μžˆλ„λ‘ μ…‹μ—… νŒŒμΌμ„ μΆ”κ°€ ν•  수 μžˆλ‹€. 적용될 ν…ŒμŠ€νŠΈ μ…‹μ—… νŒŒμΌμ€ μ•„λž˜ λͺ©λ‘μ—μ„œ μ‘΄μž¬ν•˜λŠ” νŒŒμΌμ„ λͺ¨λ‘ μ°Ύμ•„ μ‚¬μš©ν•˜κ²Œ λœλ‹€.

μžμ„Έν•œ λ‚΄μš©μ€ Jest κ΄€λ ¨ λ¬Έμ„œλ₯Ό μ°Έκ³ .

<rootDir>/src/test/@setup.ts (or .js)
<rootDir>/src/tests/@setup.ts (or .js)
<rootDir>/test/@setup.ts (or .js)
<rootDir>/tests/@setup.ts (or .js)
<rootDir>/test-setup.ts (or .js)

Test Coverage

μ•„λž˜ λͺ…λ ΉμœΌλ‘œ ν…ŒμŠ€νŠΈ 컀버리지 데이터λ₯Ό ν”„λ‘œμ νŠΈ λ‚΄ /coverage 디렉토리에 생성할 수 μžˆλ‹€.

lintest test coverage

Lint rules package

Naming

νŒ¨ν‚€μ§€λͺ…은 @lintest/rules-{ν”„λ‘œλ°”μ΄λ”λͺ…}으둜 μ •μ˜ν•˜κ³  NPM @lintest 쑰직의 μŠΉμΈμ„ λ°›μ•„ λ°°ν¬ν•¨μœΌλ‘œμ¨ CLIμ—μ„œ ν•΄λ‹Ή νŒ¨ν‚€μ§€λ₯Ό λ°›μ•„ 린트 룰을 적용 ν•  수 있게 λœλ‹€.

Package defination

package.json의 "main"으둜 μ„€μ •λœ 파일(index.js)에 μ•„λž˜μ™€ 같은 단일 ν˜•νƒœμ˜ μ •μ˜ 파일이 기본적으둜 ν•„μš”ν•˜λ‹€.
μ„€μ •κ°€λŠ₯ ν•­λͺ©μ€ prettier, lintRules, disableLintIgnore, enableCompatibility 등이 μžˆλ‹€.

prettier

  • prettier ν•­λͺ©μ€ prettier μ‚¬μš©μ΄ ν•„μš”ν•  λ•Œλ§Œ λͺ…μ‹œν•˜λ©΄ λœλ‹€.

lintRules

μ•„λž˜ μƒ˜ν”Œμ²˜λŸΌ μ„€μ •ν•΄μ£Όλ©΄ lintestμ—μ„œ 섀정에 따라 μ—¬λŸ¬ ν”ŒλŸ¬κ·ΈμΈμ„ μ‘°ν•©ν•˜μ—¬ μ΅œμ’… 린트 룰셋을 λ§Œλ“€μ–΄λ‚Έλ‹€.

  • lintRules ν•˜μœ„ ν•­λͺ©μ˜ 룰에 λŒ€ν•œ 선언은 ν”ŒλŸ¬κ·ΈμΈλ³„ prefixλ₯Ό 뢙이지 μ•Šμ•„λ„ 되며, λΆˆν•„μš”μ‹œ λͺ…μ‹œν•˜μ§€ μ•Šμ•„λ„ λœλ‹€.

    예λ₯Ό λ“€μ–΄, typescript ν•­λͺ©μ˜ '@typescript-eslint/indent' 룰을 μ •μ˜ν•  λ•Œ '@typescript-eslint/'λŠ” ꡳ이 λΆ™μ—¬μ£Όμ§€ μ•Šμ•„λ„ 'typescript' ν•­λͺ© ν•˜μœ„μ— 'indent'만으둜 선언해도 μ΅œμ’… 룰은 '@typescript-eslint/indent'둜 λ³€ν™˜λœλ‹€.

  • lintRules ν•˜μœ„ ν•­λͺ© 쀑 vue ν˜Ήμ€ react 룰이 λͺ…μ‹œλ˜λ©΄ κ΄€λ ¨ 룰셋이 ν•¨κ»˜ μ μš©λœλ‹€.

    vueλŠ” "eslint-plugin-vue", "@vue/standard", "@vue/typescript" λ“± 적용.
    reactλŠ” "eslint-plugin-jsx-a11y", "eslint-plugin-react", "eslint-plugin-react-hooks" λ“± 적용.

Sample

// index.js

module.exports = {
  prettier: {
    tabWidth: 2,
    useTabs: false,
  },
  lintRules: {
    general: {
      'comma-dangle': 'off',
      'no-console': 'off',
      'no-debugger': 'off',
    },
    typescript: {
      '@typescript-eslint/indent': ['error', 2],
    },
    react: {
      'react/jsx-boolean-value': 'off',
      'jsx-wrap-multilines': 'off', // might be specify no prefix
    },
    reactHooks: {
      'rules-of-hooks': 'error',
      'exhaustive-deps': 'warn',
    },
    vue: {
      'attribute-hyphenation': 'off',
      'vue/html-closing-bracket-spacing': 'off',
      'vue/html-indent': ['error', 2],
      'html-self-closing': 'off',
    },
    unicorn: {
      'escape-case': 'error',
    },
    promise: {
      'promise/valid-params': 'off',
    },
    standard: {},
    import: {},
    jest: {},
    lintest: {
      report: [1, 'all', 10, 300],
    },
  },
}

Etcs

린트 퍼포먼슀 ν–₯상을 μœ„ν•΄ μ•„λž˜μ™€ 같이 performance reportλ₯Ό μ½˜μ†”λ‘œ 좜λ ₯ν•  수 μžˆλ‹€.
λ¦°νŠΈμ‹œ μˆ˜ν–‰μ‹œκ°„μ„ μ²΄ν¬ν•΄λ³΄λ©΄μ„œ μ‹œκ°„μ΄ 많이 κ±Έλ¦¬λŠ” 룰에 λŒ€ν•΄ λΉ„ν™œμ„±ν™”ν•˜λ©΄ μˆ˜ν–‰μ†λ„ ν–₯상에 도움이 λœλ‹€.

$ export TIMING=1
$ npm run lint

Change Log

ν•΄λ‹Ή ν”„λ‘œμ νŠΈμ˜ 변경사항은 CHANGELOG.md 파일 μ°Έμ‘°.

License

ν•΄λ‹Ή ν”„λ‘œμ νŠΈμ˜ λΌμ΄μ„ΌμŠ€λŠ” LICENSE 파일 μ°Έμ‘°.

Keywords

lintest

FAQs

Package last updated on 24 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts