๐Ÿšจ 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.0.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 21 Oct 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