Skip to content

Commit

Permalink
feat(eslint-plugin): [restrict-template-expressions] `allowNumber: tr…
Browse files Browse the repository at this point in the history
…ue` by default (#2005)
  • Loading branch information
bradzacher committed May 10, 2020
1 parent 4a9e392 commit 2f90a5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Expand Up @@ -38,8 +38,9 @@ type Options = {
};

const defaults = {
allowNumber: false,
allowNumber: true,
allowBoolean: false,
allowAny: false,
allowNullable: false,
};
```
Expand Down
Expand Up @@ -41,7 +41,11 @@ export default util.createRule<Options, MessageId>({
},
],
},
defaultOptions: [{}],
defaultOptions: [
{
allowNumber: true,
},
],
create(context, [options]) {
const service = util.getParserServices(context);
const typeChecker = service.program.getTypeChecker();
Expand Down
Expand Up @@ -214,6 +214,7 @@ ruleTester.run('restrict-template-expressions', rule, {
code: `
const msg = \`arg = \${123}\`;
`,
options: [{ allowNumber: false }],
errors: [{ messageId: 'invalidType', line: 2, column: 30 }],
},
{
Expand All @@ -233,6 +234,7 @@ ruleTester.run('restrict-template-expressions', rule, {
declare const arg: number;
const msg = \`arg = \${arg}\`;
`,
options: [{ allowNumber: false }],
errors: [{ messageId: 'invalidType', line: 3, column: 30 }],
},
{
Expand Down

0 comments on commit 2f90a5b

Please sign in to comment.