polymer-project-config
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -11,2 +11,11 @@ # Change Log | ||
## [3.6.0] - 2017-11-28 | ||
* Added a new lint option: `filesToIgnore`. We'll never report warnings for any | ||
file that matches any of these globs. | ||
* `ignoreWarnings` is a confusing phrasing. Added the `warningsToIgnore` | ||
spelling which will be used preferentially. This was better than making the | ||
options inconsistent, or spelling the new option `ignoreFiles`. | ||
* Improved error messages when validation of a polymer.json object fails. | ||
<!-- Add new, unreleased changes here. --> | ||
## [3.5.0] - 2017-11-21 | ||
@@ -13,0 +22,0 @@ * Added static methods for constructing a ProjectConfig directly from an unvalidated JSON object, in addition to the methods for reading it from disk. |
@@ -17,3 +17,20 @@ import { ProjectBuildOptions } from './builds'; | ||
*/ | ||
warningsToIgnore?: string[]; | ||
/** | ||
* Deprecated way of spelling the `warningsToIgnore` lint option. | ||
* | ||
* Used only if `warningsToIgnore` is not specified. | ||
*/ | ||
ignoreWarnings?: string[]; | ||
/** | ||
* An array of file globs to never report warnings for. | ||
* | ||
* The globs follow [minimatch] syntax, and any file that matches any | ||
* of the listed globs will never show any linter warnings. This will | ||
* typically not have a performance benefit, as the file will usually | ||
* still need to be analyzed. | ||
* | ||
* [minimatch]: https://github.com/isaacs/minimatch | ||
*/ | ||
filesToIgnore?: string[]; | ||
} | ||
@@ -75,3 +92,4 @@ export interface ProjectOptions { | ||
* | ||
* TODO: make this method and the one below async. | ||
* TODO: in the next major version we should make this method and the one | ||
* below async. | ||
*/ | ||
@@ -92,2 +110,6 @@ static loadOptionsFromFile(filepath: string): ProjectOptions | null; | ||
* | ||
* TODO(rictic): For the next major version we should mark the constructor | ||
* private, or perhaps make it validating. Also, we should standardize the | ||
* naming scheme across the static methods on this class. | ||
* | ||
* Throws if the given JSON object is an invalid ProjectOptions. | ||
@@ -94,0 +116,0 @@ */ |
@@ -77,2 +77,11 @@ "use strict"; | ||
} | ||
// TODO(rictic): two releases after v3.5.0, start warning about | ||
// options.lint.ignoreWarnings. For now we'll start by just | ||
// making them always point to the same object. | ||
if (options.lint && options.lint.warningsToIgnore) { | ||
options.lint.ignoreWarnings = options.lint.warningsToIgnore; | ||
} | ||
else if (options.lint && options.lint.ignoreWarnings) { | ||
options.lint.warningsToIgnore = options.lint.ignoreWarnings; | ||
} | ||
return options; | ||
@@ -172,3 +181,4 @@ } | ||
* | ||
* TODO: make this method and the one below async. | ||
* TODO: in the next major version we should make this method and the one | ||
* below async. | ||
*/ | ||
@@ -210,8 +220,12 @@ static loadOptionsFromFile(filepath) { | ||
if (result.errors.length > 0) { | ||
throw result.errors[0]; | ||
const error = result.errors[0]; | ||
if (!error.property && !error.message) { | ||
throw error; | ||
} | ||
let propertyName = error.property; | ||
if (propertyName.startsWith('instance.')) { | ||
propertyName = propertyName.slice(9); | ||
} | ||
throw new Error(`Property '${propertyName}' ${error.message}`); | ||
} | ||
if (result.throwError) { | ||
throw new Error(`An error was encountered while validating the ` + | ||
`Polymer Project Config.`); | ||
} | ||
return configJsonObject; | ||
@@ -222,2 +236,6 @@ } | ||
* | ||
* TODO(rictic): For the next major version we should mark the constructor | ||
* private, or perhaps make it validating. Also, we should standardize the | ||
* naming scheme across the static methods on this class. | ||
* | ||
* Throws if the given JSON object is an invalid ProjectOptions. | ||
@@ -291,2 +309,7 @@ */ | ||
toJSON() { | ||
let lintObj = undefined; | ||
if (this.lint) { | ||
lintObj = Object.assign({}, this.lint); | ||
delete lintObj.ignoreWarnings; | ||
} | ||
const obj = { | ||
@@ -305,3 +328,3 @@ entrypoint: globRelative(this.root, this.entrypoint), | ||
builds: this.builds, | ||
lint: this.lint, | ||
lint: lintObj, | ||
}; | ||
@@ -308,0 +331,0 @@ return JSON.stringify(obj, null, 2); |
@@ -6,4 +6,11 @@ { | ||
"properties": { | ||
"filesToIgnore": { | ||
"description": "An array of file globs to never report warnings for.\n\nThe globs follow [minimatch] syntax, and any file that matches any\nof the listed globs will never show any linter warnings. This will\ntypically not have a performance benefit, as the file will usually\nstill need to be analyzed.\n\n[minimatch]: https://github.com/isaacs/minimatch", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"ignoreWarnings": { | ||
"description": "Warnings to ignore. After the rules are run, any warning that matches\none of these codes is ignored, project-wide.", | ||
"description": "Deprecated way of spelling the `warningsToIgnore` lint option.\n\nUsed only if `warningsToIgnore` is not specified.", | ||
"items": { | ||
@@ -20,2 +27,9 @@ "type": "string" | ||
"type": "array" | ||
}, | ||
"warningsToIgnore": { | ||
"description": "Warnings to ignore. After the rules are run, any warning that matches\none of these codes is ignored, project-wide.", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
} | ||
@@ -22,0 +36,0 @@ }, |
{ | ||
"name": "polymer-project-config", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "reads, validates, and shapes your polymer.json project configuration", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -82,2 +82,10 @@ /** | ||
} | ||
// TODO(rictic): two releases after v3.5.0, start warning about | ||
// options.lint.ignoreWarnings. For now we'll start by just | ||
// making them always point to the same object. | ||
if (options.lint && options.lint.warningsToIgnore) { | ||
options.lint.ignoreWarnings = options.lint.warningsToIgnore; | ||
} else if (options.lint && options.lint.ignoreWarnings) { | ||
options.lint.warningsToIgnore = options.lint.ignoreWarnings; | ||
} | ||
return options; | ||
@@ -97,3 +105,22 @@ } | ||
*/ | ||
warningsToIgnore?: string[]; | ||
/** | ||
* Deprecated way of spelling the `warningsToIgnore` lint option. | ||
* | ||
* Used only if `warningsToIgnore` is not specified. | ||
*/ | ||
ignoreWarnings?: string[]; | ||
/** | ||
* An array of file globs to never report warnings for. | ||
* | ||
* The globs follow [minimatch] syntax, and any file that matches any | ||
* of the listed globs will never show any linter warnings. This will | ||
* typically not have a performance benefit, as the file will usually | ||
* still need to be analyzed. | ||
* | ||
* [minimatch]: https://github.com/isaacs/minimatch | ||
*/ | ||
filesToIgnore?: string[]; | ||
} | ||
@@ -166,3 +193,4 @@ | ||
* | ||
* TODO: make this method and the one below async. | ||
* TODO: in the next major version we should make this method and the one | ||
* below async. | ||
*/ | ||
@@ -205,9 +233,12 @@ static loadOptionsFromFile(filepath: string): ProjectOptions|null { | ||
if (result.errors.length > 0) { | ||
throw result.errors[0]; | ||
const error = result.errors[0]!; | ||
if (!error.property && !error.message) { | ||
throw error; | ||
} | ||
let propertyName = error.property; | ||
if (propertyName.startsWith('instance.')) { | ||
propertyName = propertyName.slice(9); | ||
} | ||
throw new Error(`Property '${propertyName}' ${error.message}`); | ||
} | ||
if (result.throwError) { | ||
throw new Error( | ||
`An error was encountered while validating the ` + | ||
`Polymer Project Config.`); | ||
} | ||
return configJsonObject; | ||
@@ -219,2 +250,6 @@ } | ||
* | ||
* TODO(rictic): For the next major version we should mark the constructor | ||
* private, or perhaps make it validating. Also, we should standardize the | ||
* naming scheme across the static methods on this class. | ||
* | ||
* Throws if the given JSON object is an invalid ProjectOptions. | ||
@@ -406,2 +441,7 @@ */ | ||
toJSON(): string { | ||
let lintObj = undefined; | ||
if (this.lint) { | ||
lintObj = {...this.lint}; | ||
delete lintObj.ignoreWarnings; | ||
} | ||
const obj = { | ||
@@ -420,3 +460,3 @@ entrypoint: globRelative(this.root, this.entrypoint), | ||
builds: this.builds, | ||
lint: this.lint, | ||
lint: lintObj, | ||
}; | ||
@@ -423,0 +463,0 @@ return JSON.stringify(obj, null, 2); |
@@ -593,2 +593,15 @@ /** | ||
suite('json validation', () => { | ||
test('throws good error messages', () => { | ||
try { | ||
ProjectConfig.validateAndCreate({ lint: [] }); | ||
} catch (e) { | ||
assert.deepEqual( | ||
e.message, `Property 'lint' is not of a type(s) object`); | ||
return; | ||
} | ||
throw new Error('Expected validateAndCreate to throw for invalid config'); | ||
}); | ||
}); | ||
suite('toJSON()', () => { | ||
@@ -645,3 +658,4 @@ test('with minimal config', () => { | ||
rules: ['some-rule'], | ||
ignoreWarnings: ['some-warning'], | ||
warningsToIgnore: ['some-warning'], | ||
filesToIgnore: ["some .* glob"] | ||
} | ||
@@ -648,0 +662,0 @@ }); |
@@ -22,3 +22,5 @@ { | ||
"swPrecacheConfig": "sw.conf", | ||
"browserCapabilities": ["es2015"], | ||
"browserCapabilities": [ | ||
"es2015" | ||
], | ||
"basePath": true | ||
@@ -28,5 +30,15 @@ } | ||
"lint": { | ||
"rules": ["some-rule"], | ||
"ignoreWarnings": ["some-warning"] | ||
"rules": [ | ||
"some-rule" | ||
], | ||
"warningsToIgnore": [ | ||
"some-warning" | ||
], | ||
"ignoreWarnings": [ | ||
"this should be overridden by warningsToIgnore" | ||
], | ||
"filesToIgnore": [ | ||
"some .* glob" | ||
] | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94059
2334