Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 47668b8

Browse files
committed
rulesDirectory must be absolute, resolve all directories from config file
1 parent c98cbf4 commit 47668b8

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [v0.9.0](https://github.com/AtomLinter/linter-tslint/tree/v0.9.0) (2016-03-23)
4+
5+
- corrected ```rulesDirectory``` resolving. ```rulesDirectory``` from settings have to be absolute path [092dbc6b](https://github.com/AtomLinter/linter-tslint/commit/092dbc6be5e89d10ed8f8abfd63b3b5cde365c65) ([arusakov](https://github.com/arusakov))
6+
- [email protected] [d34b74b8](https://github.com/AtomLinter/linter-tslint/commit/d34b74b855217668d6df058e38bc7b7d6a3ddabd) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot))
7+
- [email protected] [b2873a02](https://github.com/AtomLinter/linter-tslint/commit/b2873a02415e125738c5ef6b7eda22c38da831f2) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot))
8+
39
## [v0.8.3](https://github.com/AtomLinter/linter-tslint/tree/v0.8.3) (2016-03-02)
410

511
- CHANGELOG.md [aecfe6207](https://github.com/AtomLinter/linter-tslint/commit/aecfe6207672d83ecdea3008c79034cc207bc3ea) ([arusakov](https://github.com/arusakov))

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ On first activation the plugin will install all dependencies automatically, you
1212
$ apm install linter-tslint
1313
```
1414

15+
## Settings
16+
You can configure linter-tslint by editing `~/.atom/config.cson` (choose Config... in Atom menu):
17+
```coffee
18+
'linter-tslint':
19+
# Custom rules directory (absolute path)
20+
rulesDirectory: "/path/to/rules"
21+
# Try using the local tslint package (if exist)
22+
useLocalTslint: true
23+
```
24+
1525
## Contributing
1626
If you would like to contribute enhancements or fixes, please do the following:
1727

@@ -28,6 +38,3 @@ Please note that modifications should follow these coding guidelines:
2838
- Vertical whitespace helps readability, don’t be afraid to use it.
2939

3040
Thank you for helping out!
31-
32-
## Donation
33-
[![Share the love!](https://chewbacco-stuff.s3.amazonaws.com/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KXUYS4ARNHCN8)

lib/init.coffee

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{CompositeDisposable} = require 'atom'
22
path = require 'path'
3+
fs = require 'fs'
34
requireResolve = require 'resolve'
45

56
TSLINT_MODULE_NAME = 'tslint'
@@ -10,7 +11,7 @@ module.exports =
1011
config:
1112
rulesDirectory:
1213
type: 'string'
13-
title: 'Custom rules directory'
14+
title: 'Custom rules directory (absolute path)'
1415
default: ''
1516
useLocalTslint:
1617
type: 'boolean'
@@ -28,7 +29,11 @@ module.exports =
2829
@scopes = ['source.ts', 'source.tsx']
2930
@subscriptions.add atom.config.observe 'linter-tslint.rulesDirectory',
3031
(dir) =>
31-
@rulesDirectory = dir
32+
if dir and path.isAbsolute(dir)
33+
fs.stat dir, (err, stats) =>
34+
if stats?.isDirectory()
35+
@rulesDirectory = dir
36+
3237
@subscriptions.add atom.config.observe 'linter-tslint.useLocalTslint',
3338
(use) =>
3439
@tslintCache.clear()
@@ -72,17 +77,24 @@ module.exports =
7277
text = textEditor.getText()
7378

7479
@getLinter(filePath).then (Linter) =>
75-
configuration = Linter.findConfiguration(null, filePath)
80+
configurationPath = Linter.findConfigurationPath null, filePath
81+
configuration = Linter.loadConfigurationFromPath configurationPath
82+
83+
rulesDirectory = configuration.rulesDirectory
84+
if rulesDirectory
85+
configurationDir = path.dirname configurationPath
86+
if not Array.isArray rulesDirectory
87+
rulesDirectory = [rulesDirectory]
88+
rulesDirectory = rulesDirectory.map (dir) ->
89+
path.join configurationDir, dir
7690

77-
directory = undefined
78-
if @rulesDirectory and textEditor.project?.getPaths().length
79-
directory = path.join textEditor.project.getPaths()[0],
80-
@rulesDirectory
91+
if @rulesDirectory
92+
rulesDirectory.push @rulesDirectory
8193

8294
linter = new Linter filePath, text,
83-
formatter: 'json',
95+
formatter: 'json'
8496
configuration: configuration
85-
rulesDirectory: directory
97+
rulesDirectory: rulesDirectory
8698

8799
lintResult = linter.lint()
88100

0 commit comments

Comments
 (0)