Skip to content

Commit

Permalink
Migrate eslint config, fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 26, 2024
1 parent 99e63fa commit ed38f1f
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 96 deletions.
76 changes: 0 additions & 76 deletions .eslintrc.yaml

This file was deleted.

23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GMF_EXAMPLES_JS_FILES := $(GMF_EXAMPLES_HTML_FILES:.html=.js)

GMF_APPS += mobile desktop desktop_alt iframe_api mobile_alt oeedit
GMF_APPS_JS_FILES = $(shell find contribs/gmf/apps/ -type f -name '*.js') $(shell find contribs/gmf/apps/ -type f -name '*.ts')
BUILD_JS_FILES = $(shell ls -1 *.js) $(shell ls -1 utils/*.js) $(shell find buildtools/ -type f -name '*.js') $(shell find .storybook/ -type f -name '*.js') $(shell find cypress/ -type f -name '*.js')
BUILD_JS_FILES = $(shell ls -1 *.js) $(shell ls -1 utils/*.js) $(shell find buildtools/ -type f -name '*.js') $(shell find cypress/ -type f -name '*.js')
GMF_APPS_PARTIALS_FILES = $(shell find contribs/gmf/apps/ -type f -name '*.html' -or -name '*.html.ejs')
GMF_APPS_ALL_FILES = $(shell find contribs/gmf/apps/ -type f) $(NGEO_ALL_SRC_FILES)

Expand Down Expand Up @@ -199,33 +199,38 @@ examples-hosted-apps: .build/gmf-apps.timestamp
npm run build-gmf-apps
touch $@

.build/eslint.timestamp: .eslintrc.yaml \
.build/eslint.timestamp: eslint.config.mjs .build/eslint.test.timestamp \
$(API_JS_FILES) \
$(NGEO_JS_FILES) \
$(NGEO_TEST_JS_FILES) \
$(NGEO_EXAMPLES_JS_FILES) \
$(GMF_TEST_JS_FILES) \
$(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 .build/eslint.test.timestamp, $^)
touch $@


.build/eslint.test.timestamp: test/eslint.config.mjs \
$(NGEO_TEST_JS_FILES) \
$(GMF_TEST_JS_FILES)
./node_modules/.bin/eslint --config=test/eslint.config.mjs $(filter-out test/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
2 changes: 0 additions & 2 deletions contribs/gmf/test/.eslintrc.yaml

This file was deleted.

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": "21.11.0",
"qruri": "0.0.4",
Expand Down
1 change: 0 additions & 1 deletion src/misc/php-date-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
*/

/* eslint max-len: 0 */
/* eslint valid-jsdoc: 0 */
/* eslint quotes: 0 */
/* eslint indent: 0 */
/* eslint default-case: 0 */
Expand Down
4 changes: 0 additions & 4 deletions test/.eslintrc.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions test/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import globals from 'globals';

export default [
{
languageOptions: {
globals: {
...globals.jasmine,
sinon: true,
},
},
},
];
1 change: 0 additions & 1 deletion test/spec/beforeeach.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// @ts-nocheck
/* eslint valid-jsdoc: 0 */
import angular from 'angular';
import ngeoMainmodule from 'ngeo/mainmodule';
import i18next from 'i18next';
Expand Down

0 comments on commit ed38f1f

Please sign in to comment.