Skip to content

Commit

Permalink
Migrate ESLint to use new flat config (Fixes mozmeao#42) (mozmeao#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored Jan 9, 2024
1 parent 4c96304 commit b35e701
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 5,406 deletions.
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

0 comments on commit b35e701

Please sign in to comment.