Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ESLint to use new flat config (Fixes #42) #43

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

52 changes: 0 additions & 52 deletions .eslintrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HEAD

- **js:** Migrate JS tests to jasmine-browser-runner (#40).
- **js:** Migrate ESLint to use new flat config (#42).
- **js:** Migrate JS tests to jasmine-browser-runner (#40).

# 2.0.1

Expand Down
94 changes: 94 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const js = require('@eslint/js');
const globals = require('globals');
const eslintConfigPrettier = require('eslint-config-prettier');

const rules = {
// Use type-safe equality operators
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: ['error', 'always'],

// Treat var statements as if they were block scoped
// https://eslint.org/docs/rules/block-scoped-var
'block-scoped-var': 'error',

// Disallow Use of alert, confirm, prompt
// https://eslint.org/docs/rules/no-alert
'no-alert': 'error',

// Disallow eval()
// https://eslint.org/docs/rules/no-eval
'no-eval': 'error',

// Disallow empty functions
// https://eslint.org/docs/rules/no-empty-function
'no-empty-function': 'error',

// Require radix parameter
// https://eslint.org/docs/rules/radix
radix: 'error',

// Disallow the use of `console`
// https://eslint.org/docs/rules/no-console
'no-console': 'error'
};

module.exports = [
js.configs.recommended,
eslintConfigPrettier,
{
ignores: ['dist/**/*.js', 'demo/libs/**/*.js', 'tests/dist/**/*.js']
},
{
files: ['src/**/*.js'],
languageOptions: {
ecmaVersion: 2017,
globals: {
Mozilla: true,
...globals.browser,
...globals.commonjs
}
},
rules: rules
},
{
files: ['demo/**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
Mozilla: true,
...globals.browser,
...globals.node,
...globals.commonjs
}
},
rules: rules
},
{
files: ['tests/**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
Mozilla: true,
...globals.browser,
...globals.jasmine
}
},
rules: rules
},
{
files: [
'webpack.config.js',
'webpack.test.config.js',
'eslint.config.js'
],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.node,
...globals.commonjs
}
},
rules: rules
}
];
Loading