Skip to content

Commit

Permalink
Migrate eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 26, 2024
1 parent 7bd80d5 commit 95b4ada
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 85 deletions.
76 changes: 0 additions & 76 deletions .eslintrc.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ examples-hosted-apps: .build/gmf-apps.timestamp
npm run build-gmf-apps
touch $@

.build/eslint.timestamp: .eslintrc.yaml \
.build/eslint.timestamp: eslint.config.mjs \
$(API_JS_FILES) \
$(NGEO_JS_FILES) \
$(NGEO_TEST_JS_FILES) \
Expand All @@ -208,24 +208,24 @@ examples-hosted-apps: .build/gmf-apps.timestamp
$(GMF_EXAMPLES_JS_FILES) \
$(GMF_APPS_JS_FILES) \
$(BUILD_JS_FILES)
./node_modules/.bin/eslint $(filter-out .eslintrc.yaml, $^)
./node_modules/.bin/eslint $(filter-out eslint.config.mjs, $^)
touch $@

.build/eslint-ts.timestamp: .eslintrc.yaml \
.build/eslint-ts.timestamp: eslint.config.mjs \
$(TS_FILES)
./node_modules/.bin/eslint --max-warnings=0 $(filter-out .eslintrc.yaml .eslintrc-ts.yaml, $^)
./node_modules/.bin/eslint --max-warnings=0 $(filter-out eslint.config.mjs .eslintrc-ts.yaml, $^)
touch $@

.PHONY: eslint-fix
eslint-fix: .eslintrc.yaml \
eslint-fix: eslint.config.mjs \
$(API_JS_FILES) \
$(NGEO_JS_FILES) \
$(NGEO_TEST_JS_FILES) \
$(NGEO_EXAMPLES_JS_FILES) \
$(GMF_EXAMPLES_JS_FILES) \
$(GMF_APPS_JS_FILES) \
$(BUILD_JS_FILES)
./node_modules/.bin/eslint --fix $(filter-out .eslintrc.yaml, $^)
./node_modules/.bin/eslint --fix $(filter-out eslint.config.mjs, $^)

.build/examples-hosted/partials: examples/partials/
mkdir -p $(dir $@)
Expand Down
100 changes: 100 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import js from '@eslint/js';
import {FlatCompat} from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends(
'eslint:recommended',
'plugin:jsdoc/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:wc/recommended',
'plugin:lit/recommended',
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
},

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

parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',

parserOptions: {
project: ['tsconfig-eslint.json'],
},
},

settings: {
jsdoc: {
preferredTypes: {
'[]': null,
'Array<>': '[]',
},
},
},

rules: {
'no-multi-asterisks': 'off',
'no-prototype-builtins': 'warn',
'no-case-declarations': 'warn',
'no-eq-null': 'error',
'no-multi-assign': 'error',
'no-negated-in-lhs': 'error',
'no-use-before-define': ['error', 'nofunc'],
'no-var': 'error',
'jsdoc/require-param-type': 'off',
'jsdoc/require-property-type': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/check-tag-names': 'warn',
'jsdoc/check-types': 'off',
'jsdoc/no-undefined-types': 'warn',
'jsdoc/require-returns-description': 'warn',
'jsdoc/require-param-description': 'warn',
'jsdoc/require-property-description': 'warn',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/prefer-promise-reject-errors': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
},
},
];
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@
},
"devDependencies": {
"@babel/core": "7.25.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.24.7",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-syntax-object-rest-spread": "7.8.3",
"@babel/plugin-transform-spread": "7.24.7",
"@babel/plugin-transform-typescript": "7.25.2",
"@babel/preset-env": "7.25.3",
"@babel/preset-typescript": "7.24.7",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.9.1",
"@fortawesome/fontawesome-free": "5.15.4",
"@lit/reactive-element": "1.6.3",
"@popperjs/core": "2.11.8",
"@sentry/browser": "7.118.0",
"@sentry/tracing": "7.114.0",
"@sentry/types": "7.118.0",
Expand Down Expand Up @@ -144,6 +147,7 @@
"floatthead": "2.2.5",
"fs-extra": "11.2.0",
"glob": "11.0.0",
"globals": "15.9.0",
"html-webpack-plugin": "4.5.2",
"i18next": "23.14.0",
"i18next-browser-languagedetector": "8.0.0",
Expand Down Expand Up @@ -179,7 +183,6 @@
"ol-layerswitcher": "4.1.2",
"ol-mapbox-style": "12.3.5",
"parse-absolute-css-unit": "1.0.2",
"@popperjs/core": "2.11.8",
"proj4": "2.11.0",
"puppeteer": "20.9.0",
"qruri": "0.0.4",
Expand Down

0 comments on commit 95b4ada

Please sign in to comment.