-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add & configure ESlint; incl. plugins
Issue 2096
- Loading branch information
Showing
3 changed files
with
3,966 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* global import */ | ||
|
||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import { FlatCompat } from "@eslint/eslintrc"; | ||
import path from "path"; | ||
import prettierConfig from "eslint-config-prettier"; | ||
import requirejs from "eslint-plugin-requirejs"; | ||
import { fileURLToPath } from "url"; | ||
|
||
|
||
// This chunk needed to use older style shared eslint configs, e.g. airbnb-base | ||
// mimic CommonJS variables -- not needed if using CommonJS | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname | ||
}); | ||
|
||
export default [ | ||
// This object must contain no other properties than ignores in order for it | ||
// to apply to all config objects in this array | ||
{ ignores: ["src/components/"] }, | ||
// Use the recommended config for JS files | ||
pluginJs.configs.recommended, | ||
// Use the popular airbnb-base config, but extend it with our own rules | ||
...compat.extends("airbnb-base"), | ||
// Lint all the main MetacatUI files | ||
{ | ||
name: "lint-views-models-and-collections", | ||
files: ["src/**/*.js"], | ||
plugins: { | ||
requirejs | ||
}, | ||
languageOptions: { | ||
sourceType: "commonjs", | ||
ecmaVersion: 2020, | ||
globals: { | ||
...globals.browser, | ||
...globals.amd, | ||
MetacatUI: "readonly", | ||
} | ||
}, | ||
// Use requirejs.configs.recommended.rules and some of our own rules | ||
rules: { | ||
...requirejs.configs.recommended.rules, | ||
"import/no-amd": "off", // We use AMD | ||
"no-console": "off", // We allow console.log for now | ||
"strict": ["error", "global"], // We use strict mode | ||
"func-names": "off", // require and backbone need to use unnamed functions | ||
} | ||
|
||
}, | ||
// Allow the prettier plugin to override any conflicting rules | ||
...[].concat(prettierConfig), | ||
]; |
Oops, something went wrong.