// code snippet
tslint.json
ꡬμ±:
{
"defaultSeverity": "error",
"extends": [
"tslint-eslint-rules"
],
"jsRules": {},
"rules": {}
}
tslint.json
λ₯Ό λ€μμΌλ‘ λ³κ²½ν λ
{
"defaultSeverity": "error",
"extends": "tslint-eslint-rules",
"jsRules": {},
"rules": {}
}
A path in an 'extends' option must be relative or rooted, but 'tslint-eslint-rules' is not
tslint-eslint-rules
μ κ²½λ‘λ₯Ό μ΄λ»κ² μ»μ μ μμ΅λκΉ?
tslint.json
μ tsconfig.json
νΌλνκ³ μμ΅λλ€.
λλ νΌλμ€λ½μ§ μλ€κ³ νμ ν©λλ€. 5.8.1
λ²μ μμλ λ§μ΅λλ€.
μ¬κΈ°μ κ°μ λ¬Έμ κ° μμ΅λλ€.
λ³κ²½λ¨
"extends": [
"tslint:recommended"
],
NS
"extends": "./node_modules/tslint/lib/configs/recommended"
κ³ μΉλ€.
A path in an 'extends' option must be relative or rooted, but 'xxx' is not
λ tsconfig .jsonμ΄ μλͺ»λ κ²½μ° typescript μ»΄νμΌλ¬μμ κ°μ Έμ΅λλ€. λ°λΌμ -p tslint.json
μ€μ΄κ±°λ tslint.jsonμ μμ΄μΌ νλ μ½ν
μΈ κ° tsconfig.jsonμ μΆκ°λμμ΅λλ€.
μ¬κΈ°μ λ λ€λ₯Έ νΌλμ€λ¬μ΄ μ¬μ©μκ° μμ΅λλ€.
λ€μμ μ¬μ©νμ¬ CLIμμ tslintλ₯Ό νΈμΆν©λλ€.
"lint": "tslint --project tslint.json -e src/**/*.spec.*",
μ΄κ²μ μ§λ 1λ λμ μ μλνμ΅λλ€. μ§κΈ μ°λ¦¬λ tslint 5.9.1λ‘ μ λ°μ΄νΈνκ³ λμΌν μ€λ₯κ° νμλ©λλ€.
error TS5024: Compiler option 'extends' requires a value of type string.
μ°λ¦¬μ tslint.json
μλ λ€μ 2κ°μ νμ₯μ΄ μμ΅λλ€.
{
"extends": [
"tslint:recommended",
"tslint-sonarts"
],
λ³κ²½λ μ¬νκ³Ό μ΄ λ¬Έμ λ₯Ό λ€μ κ³ μΉ μ μλ λ°©λ²μ λν΄ μ’ λ μμΈν μλ €μ£Όμκ² μ΅λκΉ?
μ€μ λ‘ κ΄λ ¨μ΄ μλ κ²½μ° tsconfigλ λ€μκ³Ό κ°μ΅λλ€.
{
"compileOnSave": false,
"compilerOptions": {
"lib": [
"dom",
"es2015"
],
"noImplicitAny": false,
"target": "es5",
"rootDir": "src",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"jsx": "preserve",
"baseUrl": "src",
"types": [
"p-elements-core",
"@types/jasmine",
"@types/underscore",
"@types/requirejs",
"../../src/types"
]
}
}
@StanLee12 μ¬μ© μ€μΈ μ νν CLI μΈμλ 무μμ
λκΉ? μ΄ μ€λ λμ λ€λ₯Έ 리ν¬ν°μ λμΌν μλͺ»λ μ€μ μ μ¬μ©νκ³ μλ€κ³ μκ°ν©λλ€. --project
νλκ·Έλ tslint.json
μλλΌ tsconfig.json
νμΌμ κ°λ¦¬μΌμΌ ν©λλ€.
@MartijnKooij v5.9μ tslint.json μμ extends
κΈ°λ₯ ꡬνμ λͺ κ°μ§ λ³κ²½ μ¬νμ΄ μμ΄ μ€μλ‘ μλͺ»λ μ€μ μ΄ μλμ λ©μ·μ΅λλ€. μμμ λ§νλ―μ΄ --project
λ tsconfig.json νμΌμ κ°λ¦¬μΌμΌ ν©λλ€. TSLint λ¬Έμ μ€ μ΄λ κ²λ --project path/to/tslint.json
κ° μ§μλλ μ¬μ© ν¨ν΄μ΄λΌκ³ μ£Όμ₯ν μ μ΄ μμ΅λλ€.
μΆκ° μ€λͺ
μ κ°μ¬λ립λλ€. @ajafffκ° --project 맀κ°λ³μλ‘ tsconfig λμ tslintλ₯Ό μ¬μ©νλ€κ³ λ§νμ λ μ΄ν΄ νμ§ λͺ»νμ΅λλ€.
λ΄ μκ°μ μ΄λκ°μ μ΄ μ€λ₯κ° ν¬ν¨λ tslint μ¬μ©μ λν λΈλ‘κ·Έ κ²μλ¬Όμ΄ μμ΅λλ€.
μ΄μ λν https://palantir.github.io/tslint/usage/cli/μ λ¬Έμλ μ νν©λλ€. μ μ΄λ μ§κΈμ κ·Έλ μ΅λλ€.)
λ€μ ν λ² κ°μ¬λ립λλ€. μμ μ±κ³Ό κΈ°ν μ¬νμ κ°μ¬λ립λλ€. μ°λ¦¬λ λ³κ²½:
"lint": "tslint --project tslint.json -e src/**/*.spec.*",
μ΄κ²μΌλ‘
"lint": "tslint --project tsconfig.json -e src/**/*.spec.*",
@ajafff @adidahiya μ λ§ μ£μ‘ν©λλ€ μ μλͺ»μ΄μμ μ λ§ κ°μ¬ν©λλ€!
μ΄ λ¬Έμ λ‘ μΈν΄ mocha-tslintλ λ μ΄μ μλνμ§ μμ΅λλ€. κ·Έλ¦¬κ³ configFilePathλ tslint.jsonμ κ°λ¦¬μΌμΌ ν©λλ€. λμ tsconfig.jsonμ μ¬μ©νλ κ²½μ°:
const lint = require('mocha-tslint');
const configFilePath = './tsconfig.json';
lint(configFilePath);
λλμ΄ κ²°κ³Όλ₯Ό μ»λλ€ :
tslint
No valid rules have been specified
νμ 5.8κ³Ό ν¨κ» μλνμ΅λλ€.
@DaveXCS mocha-tslint
κ° λκ° μλͺ»ν΄μ λ°μνμ κ°λ₯μ±μ΄ ν½λλ€. λλ κ·Έλ€μ΄ private API (runner.ts)λ₯Ό μ¬μ©νκ³ κ΅¬μ± νμΌμ -c
AND -p
μΈμλ‘ μ¬μ©νλ€κ³ μκ°ν©λλ€.
mocha-tslintμ λ¬Έμ λ₯Ό μ΄ν΄νλ €κ³ νμ§λ§ μ¬κΈ°μμ λ¬Έμ κ° λ³΄μ΄μ§ μμ΅λλ€.
const tslintConfig = Configuration.loadConfigurationFromPath(configFilePath);
fileNames.forEach((file) => test(file, tslintConfig));
const TSLint = require('tslint');
const Linter = TSLint.Linter;
const Configuration = TSLint.Configuration;
fs.readFile(file, (err, sourceBuffer) => {
const linter = new Linter(options);
const source = sourceBuffer.toString();
linter.lint(file, source.toString(), config);
@DaveXCS λ¬Έμ λ λ€μ μ€μ
λλ€. https://github.com/t-sauer/mocha-tslint/blob/0ba7f64be458cd74343a4149dff323d5bfd195a5/index.js#L24
μ΄ κ²½λ‘λ₯Ό ν΅κ³Όνμ§ μμμΌ tslint.json
(A)μ λν κ²½λ‘ νμν ν¨μ tsconfig.json
λλ λΉμ μ μν΄ λ¬Έμ λ₯Ό μ΄μμ΅λλ€ : https://github.com/t-sauer/mocha-tslint/issues/9
λΉμ μ λμμ μ£Όμ
μ κ°μ¬ν©λλ€.
cliμ --projectλ₯Ό tslint.json λμ tsconfig.jsonμΌλ‘ λ°κΎΈκ³ "mocha-tslint"(μ ν κ²μ¬λ ν¬ν¨)λ₯Ό λ€μ μμ±νμ΅λλ€.
https://gist.github.com/DaveXCS/3bd930f7093b748f551c99e80d57c578
μ΄κ²μ 좩격μ μΌλ‘ λ¬Έμνλμ§ μμμΌλ©° νΌλμ€λ½κ³ μ ν μ§κ΄μ μ΄μ§ μμ΅λλ€.
@devguyrun CLI μ¬μ© λ¬Έμ λ --project
λ₯Ό tsconfig.json
νμΌμ μ¬λ¬ λ² κ°λ¦¬ν€λλ‘ μ§μν©λλ€. λ λͺ
νν΄μ§ μ μλ€κ³ μκ°λλ©΄ μμ λ‘κ² PRμ 보λ΄μμμ€.
μ€λ₯ TS18001: 'νμ₯' μ΅μ μ κ²½λ‘λ μλ λλ 루νΈμ¬μΌ νμ§λ§ '<%= sourcedir.split('/').map(x => '..').join('/') %
/tsconfig.json'μ΄ μλλλ€.
λ€λ₯Έ μ€λ₯κ° λ°μνμ΅λλ€.
κ°μ₯ μ μ©ν λκΈ
@StanLee12 μ¬μ© μ€μΈ μ νν CLI μΈμλ 무μμ λκΉ? μ΄ μ€λ λμ λ€λ₯Έ 리ν¬ν°μ λμΌν μλͺ»λ μ€μ μ μ¬μ©νκ³ μλ€κ³ μκ°ν©λλ€.
--project
νλκ·Έλtslint.json
μλλΌtsconfig.json
νμΌμ κ°λ¦¬μΌμΌ ν©λλ€.@MartijnKooij v5.9μ tslint.json μμ
extends
κΈ°λ₯ ꡬνμ λͺ κ°μ§ λ³κ²½ μ¬νμ΄ μμ΄ μ€μλ‘ μλͺ»λ μ€μ μ΄ μλμ λ©μ·μ΅λλ€. μμμ λ§νλ―μ΄--project
λ tsconfig.json νμΌμ κ°λ¦¬μΌμΌ ν©λλ€. TSLint λ¬Έμ μ€ μ΄λ κ²λ--project path/to/tslint.json
κ° μ§μλλ μ¬μ© ν¨ν΄μ΄λΌκ³ μ£Όμ₯ν μ μ΄ μμ΅λλ€.