Skip to content

Commit 34225ac

Browse files
committed
fix(template-require-form-method): enable rule by default to match ember-template-lint
Align with upstream: bare <form> and invalid method values are now flagged without explicit configuration. Pass `false` to opt out.
1 parent 86a4d57 commit 34225ac

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

lib/rules/template-require-form-method.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const DEFAULT_CONFIG = {
77
};
88

99
function parseConfig(config) {
10-
if (config === false || config === undefined) {
10+
if (config === false) {
1111
return false;
1212
}
1313

14-
if (config === true) {
14+
if (config === true || config === undefined) {
1515
return DEFAULT_CONFIG;
1616
}
1717

@@ -88,9 +88,8 @@ module.exports = {
8888
},
8989

9090
create(context) {
91-
// When no options are provided, parseConfig(undefined) returns false and
92-
// the rule is disabled. It must be enabled explicitly via `true` or an
93-
// `allowedMethods` object.
91+
// Default-enabled: parseConfig(undefined) returns DEFAULT_CONFIG.
92+
// Pass `false` to explicitly disable the rule.
9493
const rawOption = context.options[0];
9594
const config = parseConfig(rawOption);
9695

tests/lib/rules/template-require-form-method.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ const validHbs = [
99
options: [{ allowedMethods: ['get'] }],
1010
code: '<form method="GET"></form>',
1111
},
12-
// Default behavior: when no options are provided, the rule is disabled.
13-
// A bare <form> should NOT error.
14-
'<form></form>',
15-
'<form method="NOT_A_VALID_METHOD"></form>',
1612
{ options: [true], code: '<form method="POST"></form>' },
1713
{ options: [true], code: '<form method="post"></form>' },
1814
{ options: [true], code: '<form method="GET"></form>' },
@@ -28,6 +24,17 @@ const validHbs = [
2824
];
2925

3026
const invalidHbs = [
27+
// Default-enabled: no options → rule active with POST,GET,DIALOG.
28+
{
29+
code: '<form></form>',
30+
output: '<form method="POST"></form>',
31+
errors: [{ message: DEFAULT_ERROR }],
32+
},
33+
{
34+
code: '<form method="NOT_A_VALID_METHOD"></form>',
35+
output: '<form method="POST"></form>',
36+
errors: [{ message: DEFAULT_ERROR }],
37+
},
3138
{
3239
options: [{ allowedMethods: ['get'] }],
3340
code: '<form method="POST"></form>',

0 commit comments

Comments
 (0)