Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions build-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ function RunLinters() {
$lintwitheslint = HasLinter -LinterName "eslint"
$standardpath = "$script:PACKAGE_FOLDER\node_modules\.bin\standard.cmd"
$lintwithstandard = HasLinter -LinterName "standard"
if (($libpathexists -or $srcpathexists) -and ($lintwithcoffeelint -or $lintwitheslint -or $lintwithstandard)) {
$tslintpath = "$script:PACKAGE_FOLDER\node_modules\.bin\tslint.cmd"
$lintwithtslint = HasLinter -LinterName "tslint"
if (($libpathexists -or $srcpathexists) -and ($lintwithcoffeelint -or $lintwitheslint -or $lintwithstandard -or $lintwithtslint)) {
Write-Host "Linting package..."
}

Expand All @@ -160,6 +162,23 @@ function RunLinters() {
ExitWithCode -exitcode $LASTEXITCODE
}
}

if ($lintwithtslint) {
if (Test-Path tsconfig.json) {
Write-Host "Found tsconfig.json in project root directory, enabling type checking..."
& "$tslintpath" --project tsconfig.json --type-check
}
elseif (Test-Path lib\tsconfig.json) {
Write-Host "Found tsconfig.json in lib directory, enabling type checking..."
& "$tslintpath" --project lib\tsconfig.json --type-check
} else {
Write-Host "No tsconfig.json found for lib directory, disabling type checking..."
& "$tslintpath" lib
}
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
}
}

if ($srcpathexists) {
Expand All @@ -183,9 +202,26 @@ function RunLinters() {
ExitWithCode -exitcode $LASTEXITCODE
}
}

if ($lintwithtslint) {
if (Test-Path tsconfig.json) {
Write-Host "Found tsconfig.json in project root directory, enabling type checking..."
& "$tslintpath" --project tsconfig.json --type-check
}
elseif (Test-Path lib\tsconfig.json) {
Write-Host "Found tsconfig.json in src directory, enabling type checking..."
& "$tslintpath" --project src\tsconfig.json --type-check
} else {
Write-Host "No tsconfig.json found for src directory, disabling type checking..."
& "$tslintpath" src
}
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
}
}

if ($specpathexists -and ($lintwithcoffeelint -or $lintwitheslint -or $lintwithstandard)) {
if ($specpathexists -and ($lintwithcoffeelint -or $lintwitheslint -or $lintwithstandard -or $lintwithtslint)) {
Write-Host "Linting package specs..."
if ($lintwithcoffeelint) {
& "$coffeelintpath" spec
Expand All @@ -207,6 +243,19 @@ function RunLinters() {
ExitWithCode -exitcode $LASTEXITCODE
}
}

if ($lintwithtslint) {
if (Test-Path spec\tsconfig.json) {
Write-Host "Found tsconfig.json in spec directory, enabling type checking..."
& "$tslintpath" --project spec\tsconfig.json --type-check
} else {
Write-Host "No tsconfig.json found for spec directory, disabling type checking..."
& "$tslintpath" spec
}
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,36 @@ if has_linter "standard"; then
fi
fi

if has_linter "tslint"; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomasjo Thoughts on this approach? Hard to guarantee that running tslint --project against a root-level tsconfig.json file will actually hit the spec directory, since the tsconfig can explicitly specify which files it includes... no real reason to do this for an Atom package, but technically possible. Leaning towards only assuming that it will cover the lib or src directories - if it does lint the specs, great. If not, doesn't hurt to lint them again, either with spec/tsconfig.json or just invoking tslint on the directory with type checking disabled.

if [ -e ./tsconfig.json ]; then
echo "Linting package using tslint..."
echo "Found tsconfig.json in project root directory, enabling type checking..."
./node_modules/bin/tslint --project tsconfig.json --type-check
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
elif [ -d ./lib ]; then
echo "Linting package using tslint..."
if [ -e ./lib/tsconfig.json ]; then
echo "Found tsconfig.json in lib directory, enabling type checking..."
./node_modules/.bin/tslint --project lib/tsconfig.json --type-check
else
echo "No tsconfig.json found for lib directory, disabling type checking..."
./node_modules/.bin/tslint lib
fi
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
if [ -d ./spec ]; then
echo "Linting package specs using tslint..."
if [ -e ./spec/tsconfig.json ]; then
echo "Found tsconfig.json in spec directory, enabling type checking..."
./node_modules/.bin/tslint --project spec/tsconfig.json --type-check
else
echo "No tsconfig.json found in spec directory, disabling type checking..."
./node_modules/.bin/tslint spec
fi
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
fi

if [ -d ./spec ]; then
echo "Running specs..."
"${ATOM_SCRIPT_PATH}" --test spec
Expand Down