Skip to content

Commit 1cfa7bb

Browse files
authored
chore: lint root files with prettier and eslint (#125)
* chore: hook up Prettier, lint root files, reformat * fix prettier checks on Windows * remove redundant string
1 parent 8a7306a commit 1cfa7bb

15 files changed

Lines changed: 114 additions & 81 deletions

File tree

.eslintrc.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
module.exports = {
2+
ignorePatterns: ['/build/**', 'node_modules/**'],
23
parser: '@typescript-eslint/parser',
3-
plugins: [
4-
'@typescript-eslint',
5-
'jest',
6-
],
4+
plugins: ['@typescript-eslint', 'jest', 'prettier'],
75
env: {
86
es6: true,
97
'jest/globals': true,
108
node: true,
119
},
12-
extends: [
13-
'eslint:recommended',
14-
'plugin:@typescript-eslint/recommended',
15-
],
10+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
1611
rules: {
17-
'@typescript-eslint/explicit-member-accessibility': [
18-
'error', { 'accessibility': 'no-public' },
19-
],
12+
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
2013
'@typescript-eslint/indent': ['error', 'tab'],
14+
'prettier/prettier': 'error',
2115
},
2216
};

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"printWidth": 120,
33
"tabWidth": 2,
44
"singleQuote": true,
5-
"jsxBracketSameLine": true,
5+
"bracketSameLine": true,
66
"trailingComma": "es5",
7-
"arrowParens": "avoid"
7+
"arrowParens": "avoid",
8+
"endOfLine": "auto"
89
}

build/setup/index.map.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ module.exports = {
66
testMatch: ['**/*.test.ts'],
77
testRunner: 'jest-circus/runner',
88
transform: {
9-
'^.+\\.ts$': 'ts-jest'
9+
'^.+\\.ts$': 'ts-jest',
1010
},
1111
};

ncc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ async function build(file) {
2222
const name = path.basename(file, path.extname(file));
2323
const dir = path.resolve(BUILD_DIR, name);
2424

25-
await fs.promises.mkdir(dir, { recursive: true })
25+
await fs.promises.mkdir(dir, { recursive: true });
2626

2727
for (const asset in assets) {
28-
await fs.promises.mkdir(path.join(dir, path.dirname(asset)), { recursive: true })
28+
await fs.promises.mkdir(path.join(dir, path.dirname(asset)), { recursive: true });
2929
await write(path.join(dir, asset), assets[asset].source);
3030
}
3131

@@ -36,12 +36,12 @@ async function build(file) {
3636
}
3737

3838
async function main() {
39-
const actionPath = path.resolve(__dirname, './src/actions')
39+
const actionPath = path.resolve(__dirname, './src/actions');
4040
const actionFiles = (await fs.promises.readdir(actionPath, { withFileTypes: true }))
4141
.filter(entity => entity.isFile())
4242
.map(entity => path.join(ACTION_DIR, entity.name));
4343

44-
return Promise.all(actionFiles.map(build))
44+
return Promise.all(actionFiles.map(build));
4545
}
4646

4747
main();

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"homepage": "https://github.com/expo/expo-github-action#readme",
1717
"scripts": {
1818
"test": "jest",
19-
"lint": "tsc --noEmit && eslint ./src ./tests",
19+
"lint": "tsc --noEmit && eslint .",
2020
"build": "node ncc.js",
2121
"clean": "rimraf build",
2222
"prepare": "husky install"
@@ -43,9 +43,11 @@
4343
"conventional-changelog-conventionalcommits": "^4.6.0",
4444
"eslint": "^8.2.0",
4545
"eslint-plugin-jest": "^25.2.4",
46+
"eslint-plugin-prettier": "^4.0.0",
4647
"husky": "^6.0.0",
4748
"jest": "^27.3.1",
4849
"jest-circus": "^27.3.1",
50+
"prettier": "^2.4.1",
4951
"rimraf": "^3.0.2",
5052
"semantic-release": "^17.4.4",
5153
"ts-jest": "^27.0.7",

src/actions/setup.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,17 @@ export async function setupAction(): Promise<void> {
1010
const expoVersion = await installCli('expo-cli');
1111
const easVersion = await installCli('eas-cli');
1212

13-
await group(
14-
'Checking current authenticated account',
15-
() => tools.maybeAuthenticate({
13+
await group('Checking current authenticated account', () =>
14+
tools.maybeAuthenticate({
1615
cli: expoVersion ? 'expo-cli' : easVersion ? 'eas-cli' : undefined,
1716
token: getInput('token') || undefined,
1817
username: getInput('username') || undefined,
1918
password: getInput('password') || undefined,
20-
}),
19+
})
2120
);
2221

2322
if (tools.getBoolean(getInput('patch-watchers'), true)) {
24-
await group(
25-
'Patching system watchers for the `ENOSPC` error',
26-
() => tools.maybePatchWatchers(),
27-
);
23+
await group('Patching system watchers for the `ENOSPC` error', () => tools.maybePatchWatchers());
2824
}
2925
}
3026

@@ -45,11 +41,14 @@ async function installCli(name: tools.PackageName): Promise<string | void> {
4541
cache
4642
? `Installing ${name} (${version}) from cache or with ${packager}`
4743
: `Installing ${name} (${version}) with ${packager}`,
48-
() => install({
49-
packager, version, cache,
50-
package: name,
51-
cacheKey: getInput(`${shortName}-cache-key`) || undefined,
52-
}),
44+
() =>
45+
install({
46+
packager,
47+
version,
48+
cache,
49+
package: name,
50+
cacheKey: getInput(`${shortName}-cache-key`) || undefined,
51+
})
5352
);
5453

5554
addPath(path);

src/cache.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ function getRemoteKey(config: Omit<CacheConfig, 'cacheKey'>): string {
8282
*/
8383
function handleRemoteCacheError(error: Error): boolean {
8484
const isReserveCacheError = error instanceof ReserveCacheError;
85-
const isCacheUnavailable = error.message.toLowerCase().includes(
86-
'cache service url not found',
87-
);
85+
const isCacheUnavailable = error.message.toLowerCase().includes('cache service url not found');
8886

8987
if (isReserveCacheError || isCacheUnavailable) {
9088
core.warning('Skipping remote cache storage, encountered error:');

src/tools.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ export async function maybeAuthenticate(options: AuthenticateOptions = {}): Prom
5151
env: { ...process.env, EXPO_TOKEN: options.token },
5252
});
5353
} else {
54-
core.info('Skipping token validation: no CLI installed, can\'t run `whoami`.');
54+
core.info("Skipping token validation: no CLI installed, can't run `whoami`.");
5555
}
5656

5757
return core.exportVariable('EXPO_TOKEN', options.token);
5858
}
5959

6060
if (options.username || options.password) {
6161
if (options.cli !== 'expo-cli') {
62-
return core.warning('Skipping authentication: only Expo CLI supports programmatic credentials, use `token` instead.');
62+
return core.warning(
63+
'Skipping authentication: only Expo CLI supports programmatic credentials, use `token` instead.'
64+
);
6365
}
6466

6567
if (!options.username || !options.password) {
@@ -113,7 +115,9 @@ export async function maybeWarnForUpdate(name: PackageName): Promise<void> {
113115

114116
if (semver.diff(latest, current) === 'major') {
115117
core.warning(`There is a new major version available of the Expo CLI (${latest})`);
116-
core.warning(`If you run into issues, try upgrading your workflow to "${binaryName}-version: ${semver.major(latest)}.x"`);
118+
core.warning(
119+
`If you run into issues, try upgrading your workflow to "${binaryName}-version: ${semver.major(latest)}.x"`
120+
);
117121
}
118122
}
119123

tests/actions/setup.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ describe('run', () => {
6262
mockInput({ [`${cliName}Version`]: 'latest' });
6363
await setupAction();
6464
expect(install.install).toBeCalledWith({
65-
package:
66-
packageName,
65+
package: packageName,
6766
version: 'latest',
6867
packager: 'yarn',
6968
cache: false,
@@ -101,7 +100,7 @@ describe('run', () => {
101100
packager: 'yarn',
102101
[`${cliName}Version`]: '4.2.0',
103102
[`${cliName}Cache`]: 'true',
104-
[`${cliName}CacheKey`]: 'custom-key'
103+
[`${cliName}CacheKey`]: 'custom-key',
105104
});
106105
await setupAction();
107106
expect(install.install).toBeCalledWith({
@@ -145,7 +144,7 @@ function mockInput(props: MockInputProps = {}) {
145144
case 'expo-cache':
146145
return props.expoCache || '';
147146
case 'expo-cache-key':
148-
return props.expoCacheKey || '';``
147+
return props.expoCacheKey || '';
149148
case 'eas-version':
150149
return props.easVersion || '';
151150
case 'eas-cache':

0 commit comments

Comments
 (0)