File tree Expand file tree Collapse file tree 6 files changed +78
-4
lines changed
fixtures/hierarchyWithoutRoot Expand file tree Collapse file tree 6 files changed +78
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
11
11
12
12
### Removed
13
13
14
+
15
+ ## [ 3.0.1] - 2018-05-14
16
+ ### Fixed
17
+ - Addressed issue, from @ntwb , [ #79 ] ( https://github.com/tclindner/npm-package-json-lint/issues/79 ) .
18
+
19
+
14
20
## [ 3.0.0] - 2018-05-09
15
21
### Added
16
22
- Added support for glob based package.json file detection. Addresses [ #74 ] ( https://github.com/tclindner/npm-package-json-lint/issues/74 ) from @dnepro .
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " npm-package-json-lint" ,
3
- "version" : " 3.0.0 " ,
3
+ "version" : " 3.0.1 " ,
4
4
"description" : " Configurable linter for package.json files." ,
5
5
"keywords" : [
6
6
" lint" ,
Original file line number Diff line number Diff line change @@ -128,9 +128,9 @@ class Config {
128
128
config = ConfigFile . load ( javaScriptConfigFilePath , this ) ;
129
129
}
130
130
131
- if ( config . hasOwnProperty ( 'root' ) && ! config . root ) {
132
- const parentDir = path . resolve ( directory , '../' ) ;
133
- const parentConfig = this . getProjectHierarchyConfig ( parentDir ) ;
131
+ if ( ! config . hasOwnProperty ( 'root' ) || ! config . root ) {
132
+ const parentPackageJsonFile = path . resolve ( directory , '../' , 'package.json ') ;
133
+ const parentConfig = this . getProjectHierarchyConfig ( parentPackageJsonFile ) ;
134
134
135
135
// Merge base object
136
136
const mergedConfig = Object . assign ( { } , parentConfig , config ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " npm-package-json-lint" ,
3
+ "version" : " 0.1.0" ,
4
+ "description" : " CLI app for linting package.json files." ,
5
+ "keywords" : [
6
+ " lint"
7
+ ],
8
+ "homepage" : " https://github.com/tclindner/npm-package-json-lint" ,
9
+ "author" : " Thomas Lindner" ,
10
+ "repository" : {
11
+ "type" : " git" ,
12
+ "url" : " https://github.com/tclindner/npm-package-json-lint"
13
+ },
14
+ "devDependencies" : {
15
+ "mocha" : " ^2.4.5"
16
+ },
17
+ "npmPackageJsonLintConfig" : {
18
+ "root" : " true" ,
19
+ "rules" : {
20
+ "require-author" : " off" ,
21
+ "version-format" : " error"
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " npm-package-json-lint" ,
3
+ "version" : " 0.1.0" ,
4
+ "description" : " CLI app for linting package.json files." ,
5
+ "keywords" : [
6
+ " lint"
7
+ ],
8
+ "homepage" : " https://github.com/tclindner/npm-package-json-lint" ,
9
+ "author" : " Thomas Lindner" ,
10
+ "repository" : {
11
+ "type" : " git" ,
12
+ "url" : " https://github.com/tclindner/npm-package-json-lint"
13
+ },
14
+ "devDependencies" : {
15
+ "mocha" : " ^2.4.5"
16
+ },
17
+ "npmPackageJsonLintConfig" : {
18
+ "rules" : {
19
+ "require-author" : " error"
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change @@ -752,6 +752,28 @@ describe('Config Unit Tests', function() {
752
752
ConfigFile . load . restore ( ) ;
753
753
} ) ;
754
754
755
+ it ( 'and package.json prop exists and root is not set, the config object should returned' , function ( ) {
756
+ const options = {
757
+ configFile : '' ,
758
+ cwd : process . cwd ( ) ,
759
+ useConfigFiles : false ,
760
+ rules : { }
761
+ } ;
762
+ const config = new Config ( options , linterContext ) ;
763
+
764
+ const expectedConfigObj = {
765
+ root : true ,
766
+ rules : {
767
+ 'require-author' : 'error' ,
768
+ 'version-format' : 'error'
769
+ }
770
+ } ;
771
+ const filePath = './tests/fixtures/hierarchyWithoutRoot/subdirectory/package.json' ;
772
+ const result = config . getProjectHierarchyConfig ( filePath ) ;
773
+
774
+ result . should . deep . equal ( expectedConfigObj ) ;
775
+ } ) ;
776
+
755
777
it ( 'and package.json prop exists and has no prop, the config object should returned' , function ( ) {
756
778
const options = {
757
779
configFile : '' ,
You can’t perform that action at this time.
0 commit comments