Skip to content

Commit

Permalink
feat: add aliases to readonly props
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 19, 2023
1 parent 6d0bea0 commit 3fd5eaf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/read-only-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
import { extendsSfCommand, isInCommandDirectory } from '../shared/commands';

const props = ['summary', 'description', 'examples', 'flags', 'requiresProject', 'hidden'];
const props = ['summary', 'description', 'examples', 'flags', 'requiresProject', 'hidden', 'aliases'];

export const readOnlyProperties = ESLintUtils.RuleCreator.withoutDocs({
meta: {
Expand Down
52 changes: 52 additions & 0 deletions test/rules/read-only-properties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,58 @@ export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
public static readonly description = 'bar'
public static readonly summary = 'baz'
}
`,
},
{
name: 'aliases only modifies top-level, not flags (public)',
filename: path.normalize('src/commands/foo.ts'),
errors: [
{
messageId: 'public',
data: { prop: 'aliases' },
},
],
output: `
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
public static readonly aliases = 'bar'
public static readonly flags = {
foo: flags.string({char: 'f', description: 'foo', aliases: ['g']}),
}
}
`,
code: `
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
protected static readonly aliases = 'bar'
public static readonly flags = {
foo: flags.string({char: 'f', description: 'foo', aliases: ['g']}),
}
}
`,
},
{
name: 'aliases only modifies top-level, not flags (readonly)',
filename: path.normalize('src/commands/foo.ts'),
errors: [
{
messageId: 'readonly',
data: { prop: 'aliases' },
},
],
code: `
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
protected static aliases = 'bar'
public static readonly flags = {
foo: flags.string({char: 'f', description: 'foo', aliases: ['g']}),
}
}
`,
output: `
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
protected static readonly aliases = 'bar'
public static readonly flags = {
foo: flags.string({char: 'f', description: 'foo', aliases: ['g']}),
}
}
`,
},
],
Expand Down

0 comments on commit 3fd5eaf

Please sign in to comment.