Skip to content

Commit a28b224

Browse files
committed
style: remove leading '_'
The TypeScript compiler automatically ignores imports, function arguments, type parameter declarations, and object destructuring variables prefixed with an underscore https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/ rules/no-unused-vars-experimental.md
1 parent d9acdfd commit a28b224

20 files changed

+402
-389
lines changed

.eslintrc.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
const booleanVarPrefix = ['is', 'should', 'has', 'can', 'did', 'will'];
2+
13
const booleanVariable = {
24
types: ['boolean'],
35
format: ['PascalCase'],
4-
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
6+
prefix: booleanVarPrefix,
7+
};
8+
9+
const booleanConst = {
10+
types: ['boolean'],
11+
prefix: booleanVarPrefix.map(prefix => `${prefix.toUpperCase()}_`),
512
};
613

714
module.exports = {
@@ -62,21 +69,47 @@ module.exports = {
6269
{
6370
selector: 'variableLike',
6471
format: ['camelCase'],
65-
leadingUnderscore: 'allow',
72+
},
73+
{
74+
selector: 'variable',
75+
modifiers: ['const'],
76+
format: ['camelCase'],
77+
},
78+
{
79+
selector: 'variable',
80+
modifiers: ['const'],
81+
format: ['camelCase'],
82+
...booleanConst,
6683
},
6784
{
6885
selector: 'variable',
6986
...booleanVariable,
7087
},
88+
{
89+
selector: 'parameter',
90+
format: ['camelCase'],
91+
leadingUnderscore: 'allow',
92+
},
7193
{
7294
selector: 'parameter',
7395
...booleanVariable,
96+
leadingUnderscore: 'allow',
7497
},
7598
{
7699
selector: 'memberLike',
77100
modifiers: ['private'],
78101
format: ['camelCase'],
79-
leadingUnderscore: 'require',
102+
},
103+
{
104+
selector: 'memberLike',
105+
modifiers: ['static', 'readonly'],
106+
format: ['UPPER_CASE'],
107+
},
108+
{
109+
selector: 'property',
110+
modifiers: ['static', 'readonly'],
111+
format: ['UPPER_CASE'],
112+
...booleanConst,
80113
},
81114
{
82115
selector: 'typeLike',

scripts/check-not-staged.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import gitP from 'simple-git';
33
const git = gitP();
44

55
void (async (): Promise<void> => {
6-
const _gitStatus = await git.status();
7-
const _notStaged = _gitStatus.files.filter(status => status.working_dir !== ' ');
8-
if (_notStaged.length > 0) {
6+
const gitStatus = await git.status();
7+
const notStaged = gitStatus.files.filter(status => status.working_dir !== ' ');
8+
if (notStaged.length > 0) {
99
console.error(`Changes not staged present! Please run 'git add' or 'git checkout'!`);
10-
_notStaged.map(file => file.path).forEach(file => console.error(file));
10+
notStaged.map(file => file.path).forEach(file => console.error(file));
1111
process.exitCode = 1;
1212
}
1313
})();

scripts/githubActionsDepGen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ const ymlDep = safeLoad(ymlDepContent);
1212
const dependencies = ((ymlDep as any).jobs.dummy.steps as { uses: string }[])
1313
.map(step => step.uses)
1414
.reduce((list, dep) => {
15-
const _match = /.*\/(.*)@.*/.exec(dep);
15+
const match = /.*\/(.*)@.*/.exec(dep);
1616

17-
if (_match === null) {
17+
if (match === null) {
1818
throw new Error(`Incorrect format for dependency - ${dep}`);
1919
}
2020

21-
const _key = _match[1];
21+
const key = match[1];
2222
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
23-
(list as any)[_key] = dep;
23+
(list as any)[key] = dep;
2424

2525
return list;
2626
}, {});

scripts/publish-package.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { get, set } from 'lodash';
44
const packageJSON = require('../package.json');
55

66
function deleteUnwantedKeys(): void {
7-
const _keysToDelete = ['devDependencies', 'scripts', 'husky'];
7+
const keysToDelete = ['devDependencies', 'scripts', 'husky'];
88

99
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
10-
_keysToDelete.forEach(key => delete packageJSON[key]);
10+
keysToDelete.forEach(key => delete packageJSON[key]);
1111
}
1212

1313
function renameDistPath(): void {
14-
const _pathsToFix = ['main', 'bin.recursive-copy'];
14+
const pathsToFix = ['main', 'bin.recursive-copy'];
1515

16-
_pathsToFix.forEach(path => {
16+
pathsToFix.forEach(path => {
1717
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18-
let _value: string = get(packageJSON, path);
19-
_value = _value.replace('dist/', '');
20-
set(packageJSON, path, _value);
18+
let value: string = get(packageJSON, path);
19+
value = value.replace('dist/', '');
20+
set(packageJSON, path, value);
2121
});
2222
}
2323

src/bootstrap-cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export async function bootstrapCli(cliArgs?: string[]): Promise<void> {
1414
} = cliOptionsKeysToCopy.reduce(
1515
(prev, key) => {
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
17-
const _value = (argv as any)[key];
18-
if (_value != undefined) {
17+
const value = (argv as any)[key];
18+
if (value != undefined) {
1919
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
20-
prev[key] = _value;
20+
prev[key] = value;
2121
}
2222
return prev;
2323
},

0 commit comments

Comments
 (0)