Skip to content

Commit 0f90c0d

Browse files
author
devmax214
committed
Fix lint errors
1 parent fb202f6 commit 0f90c0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3212
-1345
lines changed

.erb/configs/webpack.config.eslint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/* eslint import/no-unresolved: off, import/no-self-import: off */
1+
/* eslint-disable import/no-unresolved, import/no-self-import, @typescript-eslint/no-var-requires */
22

33
module.exports = require('./webpack.config.renderer.dev').default;

.erb/configs/webpack.config.main.prod.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/require-hook */
12
/**
23
* Webpack config for production electron main process
34
*/

.erb/configs/webpack.config.renderer.dev.dll.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/require-hook, @typescript-eslint/no-var-requires */
12
/**
23
* Builds the DLL for development electron renderer process
34
*/

.erb/configs/webpack.config.renderer.dev.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ if (
3232
) {
3333
console.log(
3434
chalk.black.bgYellow.bold(
35-
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"',
36-
),
35+
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
36+
)
3737
);
3838
execSync('npm run postinstall');
3939
}
@@ -193,7 +193,7 @@ const configuration: webpack.Configuration = {
193193
let args = ['run', 'start:main'];
194194
if (process.env.MAIN_ARGS) {
195195
args = args.concat(
196-
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat(),
196+
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat()
197197
);
198198
}
199199
spawn('npm', args, {

.erb/configs/webpack.config.renderer.prod.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/require-hook */
12
/**
23
* Build config for electron renderer process
34
*/

.erb/configs/webpack.paths.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/require-hook, @typescript-eslint/no-var-requires */
12
const path = require('path');
23

34
const rootPath = path.join(__dirname, '../..');

.erb/scripts/.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"no-console": "off",
44
"global-require": "off",
55
"import/no-dynamic-require": "off",
6-
"import/no-extraneous-dependencies": "off"
6+
"import/no-extraneous-dependencies": "off",
7+
"jest/require-hook": "off"
78
}
89
}

.erb/scripts/check-build-exists.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js');
1010
if (!fs.existsSync(mainPath)) {
1111
throw new Error(
1212
chalk.whiteBright.bgRed.bold(
13-
'The main process is not built yet. Build it by running "npm run build:main"',
14-
),
13+
'The main process is not built yet. Build it by running "npm run build:main"'
14+
)
1515
);
1616
}
1717

1818
if (!fs.existsSync(rendererPath)) {
1919
throw new Error(
2020
chalk.whiteBright.bgRed.bold(
21-
'The renderer process is not built yet. Build it by running "npm run build:renderer"',
22-
),
21+
'The renderer process is not built yet. Build it by running "npm run build:renderer"'
22+
)
2323
);
2424
}

.erb/scripts/check-native-dep.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@ if (dependencies) {
1616
// because of a devDependency then that is okay. Warn when it is installed
1717
// because of a dependency
1818
const { dependencies: dependenciesObject } = JSON.parse(
19-
execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString(),
19+
execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString()
2020
);
2121
const rootDependencies = Object.keys(dependenciesObject);
2222
const filteredRootDependencies = rootDependencies.filter((rootDependency) =>
23-
dependenciesKeys.includes(rootDependency),
23+
dependenciesKeys.includes(rootDependency)
2424
);
2525
if (filteredRootDependencies.length > 0) {
2626
const plural = filteredRootDependencies.length > 1;
2727
console.log(`
2828
${chalk.whiteBright.bgYellow.bold(
29-
'Webpack does not work with native dependencies.',
29+
'Webpack does not work with native dependencies.'
3030
)}
3131
${chalk.bold(filteredRootDependencies.join(', '))} ${
3232
plural ? 'are native dependencies' : 'is a native dependency'
3333
} and should be installed inside of the "./release/app" folder.
3434
First, uninstall the packages from "./package.json":
3535
${chalk.whiteBright.bgGreen.bold('npm uninstall your-package')}
3636
${chalk.bold(
37-
'Then, instead of installing the package to the root "./package.json":',
37+
'Then, instead of installing the package to the root "./package.json":'
3838
)}
3939
${chalk.whiteBright.bgRed.bold('npm install your-package')}
4040
${chalk.bold('Install the package to "./release/app/package.json"')}
4141
${chalk.whiteBright.bgGreen.bold(
42-
'cd ./release/app && npm install your-package',
42+
'cd ./release/app && npm install your-package'
4343
)}
4444
Read more about native dependencies at:
4545
${chalk.bold(
46-
'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure',
46+
'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure'
4747
)}
4848
`);
4949
process.exit(1);

.erb/scripts/check-node-env.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export default function checkNodeEnv(expectedEnv) {
88
if (process.env.NODE_ENV !== expectedEnv) {
99
console.log(
1010
chalk.whiteBright.bgRed.bold(
11-
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`,
12-
),
11+
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`
12+
)
1313
);
1414
process.exit(2);
1515
}

.erb/scripts/check-port-in-use.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ detectPort(port, (_err, availablePort) => {
77
if (port !== String(availablePort)) {
88
throw new Error(
99
chalk.whiteBright.bgRed.bold(
10-
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start`,
11-
),
10+
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start`
11+
)
1212
);
1313
} else {
1414
process.exit(0);

.erb/scripts/notarize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports.default = async function notarizeMacos(context) {
1616
!('APPLE_ID' in process.env && 'APPLE_APP_SPECIFIC_PASSWORD' in process.env)
1717
) {
1818
console.warn(
19-
'Skipping notarizing step. APPLE_ID and APPLE_APP_SPECIFIC_PASSWORD env variables must be set',
19+
'Skipping notarizing step. APPLE_ID and APPLE_APP_SPECIFIC_PASSWORD env variables must be set'
2020
);
2121
return;
2222
}

.eslintrc.js

+116-18
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,132 @@
1-
module.exports = {
2-
extends: 'erb',
3-
plugins: ['@typescript-eslint'],
1+
const common = {
2+
env: {
3+
node: true,
4+
es6: true,
5+
'jest/globals': true,
6+
},
7+
plugins: ['prettier', 'jest', 'markdown', 'jsonc'],
8+
extends: [
9+
'airbnb-base',
10+
'prettier',
11+
'plugin:jest/all',
12+
'plugin:json/recommended',
13+
],
414
rules: {
5-
// A temporary hack related to IDE not resolving correct package.json
615
'import/no-extraneous-dependencies': 'off',
716
'react/react-in-jsx-scope': 'off',
817
'react/jsx-filename-extension': 'off',
18+
'prettier/prettier': 'error',
19+
'jest/unbound-method': 'off',
20+
'jest/no-disabled-tests': 'warn',
21+
'jest/no-focused-tests': 'error',
22+
'jest/no-identical-title': 'error',
23+
'jest/prefer-to-have-length': 'warn',
24+
'jest/valid-expect': 'error',
25+
'jest/expect-expect': 'off',
26+
'jest/prefer-expect-assertions': 'off',
27+
'jest/no-test-return-statement': 'off',
28+
'import/prefer-default-export': 'off',
929
'import/extensions': 'off',
1030
'import/no-unresolved': 'off',
1131
'import/no-import-module-exports': 'off',
32+
'no-console': 'off',
33+
'no-iterator': 'off',
34+
'no-restricted-syntax': 'off',
35+
'no-await-in-loop': 'off',
1236
'no-shadow': 'off',
13-
'@typescript-eslint/no-shadow': 'error',
1437
'no-unused-vars': 'off',
38+
'no-underscore-dangle': 'off',
39+
'no-plusplus': 'off',
40+
'consistent-return': 'off',
41+
camelcase: 'off',
42+
'jsonc/indent': ['error', 2],
43+
'@typescript-eslint/no-shadow': 'error',
1544
'@typescript-eslint/no-unused-vars': 'error',
1645
},
17-
parserOptions: {
18-
ecmaVersion: 2022,
19-
sourceType: 'module',
46+
globals: {
47+
fetch: true,
48+
window: true,
49+
document: true,
50+
__CDN_URL__: true,
51+
__DEV__: true,
52+
__TEST__: true,
53+
__CLIENT__: true,
54+
__SERVER__: true,
55+
__GRAPHQL_ENDPOINT__: true,
56+
__SSR__: true,
57+
__PERSIST_GQL__: true,
58+
__API_URL__: true,
59+
__WEBSITE_URL__: true,
60+
__FRONTEND_BUILD_DIR__: true,
2061
},
21-
settings: {
22-
'import/resolver': {
23-
// See https://github.com/benmosher/eslint-plugin-import/issues/1396#issuecomment-575727774 for line below
24-
node: {},
25-
webpack: {
26-
config: require.resolve('./.erb/configs/webpack.config.eslint.ts'),
62+
};
63+
64+
module.exports = {
65+
root: true,
66+
overrides: [
67+
{
68+
/*
69+
eslint-plugin-markdown only finds javascript code block snippet.
70+
For specific spec, refer to https://github.com/eslint/eslint-plugin-markdown
71+
*/
72+
files: ['**/*.js', '**/*.md'],
73+
...common,
74+
},
75+
{
76+
files: ['**/*.ts'],
77+
parser: '@typescript-eslint/parser',
78+
env: common.env,
79+
plugins: [...common.plugins, '@typescript-eslint'],
80+
extends: [
81+
...common.extends,
82+
'plugin:@typescript-eslint/recommended',
83+
'plugin:import/errors',
84+
'plugin:import/warnings',
85+
'plugin:import/typescript',
86+
],
87+
rules: {
88+
...common.rules,
89+
'@typescript-eslint/explicit-function-return-type': 'off',
90+
},
91+
settings: {
92+
'import/resolver': {
93+
node: {
94+
extensions: [
95+
'.js',
96+
'.jsx',
97+
'.ts',
98+
'.d.ts',
99+
'.tsx',
100+
'.graphql',
101+
'.gql',
102+
],
103+
},
104+
typescript: {
105+
// alwaysTryTypes: true,
106+
// paths: './tsconfig.json',
107+
},
108+
},
27109
},
28-
typescript: {},
29110
},
30-
'import/parsers': {
31-
'@typescript-eslint/parser': ['.ts', '.tsx'],
111+
{
112+
files: ['**/store/models/*.ts'],
113+
rules: {
114+
'no-underscore-dangle': 'off',
115+
'no-param-reassign': 'off',
116+
'func-names': 'off',
117+
},
32118
},
33-
},
119+
{
120+
files: ['**/services/*.ts'],
121+
rules: {
122+
'no-useless-constructor': 'off',
123+
},
124+
},
125+
{
126+
files: ['**/server/**/store/**/*.ts'],
127+
rules: {
128+
'jest/require-hook': 'off',
129+
},
130+
},
131+
],
34132
};

babel.config.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
compact: false,
3+
presets: [
4+
'@babel/preset-typescript',
5+
'@babel/preset-react',
6+
['@babel/preset-env', { modules: 'commonjs', loose: true }],
7+
],
8+
plugins: [
9+
'@babel/plugin-transform-modules-commonjs',
10+
'@babel/plugin-transform-destructuring',
11+
'@babel/plugin-transform-for-of',
12+
'@babel/plugin-transform-regenerator',
13+
'@babel/plugin-transform-runtime',
14+
'@babel/plugin-syntax-dynamic-import',
15+
'@babel/plugin-proposal-class-properties',
16+
['@babel/plugin-proposal-decorators', { legacy: true }],
17+
'@babel/plugin-proposal-object-rest-spread',
18+
],
19+
env: {
20+
production: {
21+
compact: true,
22+
},
23+
},
24+
};

lint-staged.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'*.{js,jsx,ts,tsx,json,md}': ['prettier --write', 'git add'],
3+
// '*.{ts,tsx}': ['eslint --fix'], // this can be tested
4+
};

0 commit comments

Comments
 (0)