Skip to content

Commit

Permalink
Migrate to eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
campersau committed Oct 3, 2024
1 parent d6f3ba0 commit 37414b6
Show file tree
Hide file tree
Showing 37 changed files with 854 additions and 653 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc.json

This file was deleted.

3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ public/source/
public/vendor/

# Ignore dot-files
.eslintignore
.eslintrc.json
.gitattributes
.mochaclicktest.json
.mochatest.json
.prettierignore
.prettierrc
appveyor.yml
eslint.config.mjs
tsconfig.json

# Ignore docs
Expand Down
15 changes: 0 additions & 15 deletions clicktests/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions clicktests/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class Environment {
timeout: 2000,
}); // not all ref actions opens dialog, this line may throw exception.
await this.awaitAndClick('.modal-dialog .btn-primary');
} catch (err) {
} catch (_) {
/* ignore */
}
await this.waitForElementHidden(`[data-ta-action="${action}"]:not([style*="display: none"])`);
Expand Down Expand Up @@ -396,7 +396,7 @@ class Environment {
// Usually these events are triggered by mouse movements, or api calls
// and etc. This function is to help mimic those movements.
triggerProgramEvents() {
return this.page.evaluate((_) => {
return this.page.evaluate(() => {
const isActive = ungit.programEvents.active;
if (!isActive) {
ungit.programEvents.active = true;
Expand Down
3 changes: 1 addition & 2 deletions clicktests/spec.generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const amendCommit = async () => {
try {
await environment.page.waitForSelector('.amend-button', { visible: true, timeout: 2000 });
await environment.click('.amend-button');
} catch (err) {
} catch (_) {
await environment.click('.amend-link');
}
await environment.ensureRedraw();
Expand Down Expand Up @@ -156,7 +156,6 @@ describe('[GENERIC]', () => {
await environment.waitForElementHidden('.files .file .btn-default');
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip('Should be possible to patch a file', async () => {

Check warning on line 159 in clicktests/spec.generic.js

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest)

Unexpected skipped mocha test
await changeTestFile(`${testRepoPaths[0]}/testfile.txt`, testRepoPaths[0]);
// .patch('patch')
Expand Down
11 changes: 0 additions & 11 deletions components/.eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion components/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HomeRepositoryViewModel {
.then((remote) => {
this.remote(remote.address.replace(/\/\/.*?@/, '//***@'));
})
.catch((err) => {
.catch(() => {
this.remote('');
});
}
Expand Down
4 changes: 2 additions & 2 deletions components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LoginViewModel {
this.status('login');
}
})
.catch((err) => {});
.catch(() => {});
}

updateNode(parentElement) {
Expand All @@ -32,7 +32,7 @@ class LoginViewModel {
login() {
this.server
.postPromise('/login', { username: this.username(), password: this.password() })
.then((res) => {
.then(() => {
this.loggedIn.dispatch();
this.status('loggedIn');
})
Expand Down
2 changes: 1 addition & 1 deletion components/path/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SubRepositoryViewModel {
.then((remote) => {
this.remote(remote.address.replace(/\/\/.*?@/, '//***@'));
})
.catch((err) => {
.catch(() => {
this.remote('');
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/remotes/remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class RemotesViewModel {
errorMessage = `Ungit has failed to fetch a remote. ${err.res.body.error}`;
stdout = err.res.body.stdout;
stderr = err.res.body.stderr;
} catch (e) {
} catch (_) {
errorMessage = '';
}

Expand Down
2 changes: 1 addition & 1 deletion components/repository/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RepositoryViewModel {
});
}
})
.catch((err) => {
.catch(() => {
this.parentModuleLink(undefined);
this.parentModulePath(undefined);
});
Expand Down
138 changes: 138 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import js from '@eslint/js';
import globals from 'globals';
import mochaPlugin from 'eslint-plugin-mocha';
import nodePlugin from 'eslint-plugin-n';
import prettierPlugin from 'eslint-plugin-prettier/recommended';

export default [
{
ignores: ['public/js', '**/*.bundle.js'],
},

js.configs.recommended,
mochaPlugin.configs.flat.recommended,
nodePlugin.configs['flat/recommended'],
prettierPlugin,

// global
{
rules: {
'no-unused-vars': [
'error',
{
caughtErrors: 'none',
},
],
},
},

// components
{
files: ['components/**'],

languageOptions: {
globals: {
...globals.browser,
ungit: 'readonly',
},
},

rules: {
'n/no-missing-require': 'off',
'n/no-unsupported-features/node-builtins': 'off',
},
},

// public/source
{
files: ['public/source/**'],

languageOptions: {
globals: {
...globals.browser,
io: 'readonly',
jQuery: 'writable',
Raven: 'readonly',
ungit: 'readonly',
},
},

rules: {
'no-prototype-builtins': 'off',
'n/no-missing-require': 'off',
'n/no-unsupported-features/node-builtins': 'off',
},
},

// public/main.js
{
files: ['public/main.js'],

rules: {
'n/no-unpublished-require': [
'error',
{
allowModules: ['electron'],
},
],
},
},

// source
{
files: ['source/**'],

rules: {
'no-control-regex': 'off',
'n/no-process-exit': 'off',
},
},

// scripts
{
files: ['scripts/**'],
},

// test
{
files: ['test/**'],

languageOptions: {
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
},
},

rules: {
'mocha/no-mocha-arrows': 'off',
},
},

// clicktests
{
files: ['clicktests/**'],

languageOptions: {
globals: {
...globals.browser,
ungit: 'readonly',
},
},

rules: {
'mocha/no-mocha-arrows': 'off',
'mocha/no-setup-in-describe': 'off',
},
},

// eslint.config.mjs
{
files: ['eslint.config.mjs'],

languageOptions: {
sourceType: 'module',
},
},
];
Loading

0 comments on commit 37414b6

Please sign in to comment.