Skip to content

Commit

Permalink
💡️Corrected error.statusCode rule to deprecate error.code instead (#259)
Browse files Browse the repository at this point in the history
refs #144
refs #137

- Overridden GS001-DEPR-ESC v2 rule in canary set
- The original {{statusCode}} deprecation (#137) was a mistake and what was meant to be deprecated is {{code}} (ref. https://github.com/TryGhost/Ghost/pull/9144/files#diff-6b41d6f0ef148f7d202931a87d5c4130R85)
- `statusCode` was meant to be used everywhere similarly to this change - TryGhost/Ghost@02199c6
  • Loading branch information
naz authored Sep 19, 2019
1 parent 701467c commit 2ebd9fe
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
10 changes: 10 additions & 0 deletions lib/specs/canary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ let rules = {
details: oneLineTrim`Please change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v3"}}</code>.<br>
If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v3".<br>
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
},
// Updated v2 rules
'GS001-DEPR-ESC': {
level: 'error',
rule: 'Replace <code>{{error.code}}</code> with <code>{{error.statusCode}}</code>',
details: oneLineTrim`The usage of <code>{{error.code}}</code> is deprecated and should be replaced with <code>{{error.statusCode}}</code>.<br>
When in <code>error</code> context, e. g. in the <code>error.hbs</code> template, replace <code>{{code}}</code> with <code>{{statusCode}}</code>.<br>
Find more information about the <code>error.hbs</code> template <a href="${docsBaseUrl}structure/#errorhbs" target=_blank>here</a>.`,
regex: /{{\s*?(?:error\.)?(code)\s*?}}/g,
helper: '{{error.code}}'
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/001-deprecations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ describe('001 Deprecations', function () {
output.results.fail['GS001-DEPR-IUA'].should.be.a.ValidFailObject();
output.results.fail['GS001-DEPR-IUA'].failures.length.should.eql(1);

// {{error.statusCode}}
// {{error.code}} / {{code}}
output.results.fail['GS001-DEPR-ESC'].should.be.a.ValidFailObject();
output.results.fail['GS001-DEPR-ESC'].failures.length.should.eql(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{author_profile_image}}

{{#if error}}
{{error.statusCode}}
{{error.code}}
{{/if}}

{{#each}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{statusCode}}
{{code}}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{{author_image}}

{{#if error}}
{{error.statusCode}}
{{error.code}}
{{/if}}

{{#each}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{statusCode}}
{{code}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

{{#get "posts" include="tags,authors" filter="authors:{{primary_author.slug}}+id:-{{id}}" fields="authors"}}
{{#foreach posts}}
{{title}}
{{title}}
{{/foreach}}
{{/get}}

{{!-- invalid usage of author property. Will not be detected. --}}
{{author_profile_image}}

{{authors[0].cover}}
{{error.code}}
{{error.statusCode}}
</body>
{{ghost_foot}}
</html>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{code}}
{{statusCode}}

0 comments on commit 2ebd9fe

Please sign in to comment.