Skip to content

Commit

Permalink
Upgrade lint to latest version (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM authored Oct 22, 2024
1 parent 387d072 commit 30d9ad4
Show file tree
Hide file tree
Showing 12 changed files with 638 additions and 2,606 deletions.
133 changes: 0 additions & 133 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion bin/gl-style-validate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-disable no-process-exit */

import minimist from 'minimist';
import rw from 'rw';
Expand Down
18 changes: 9 additions & 9 deletions build/generate-style-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ function objectDeclaration(key, properties) {
function objectType(properties, indent) {
return `{
${Object.keys(properties)
.filter(k => k !== '*')
.map(k => ` ${indent}${propertyDeclaration(k, properties[k])}`)
.join(',\n')}
.filter(k => k !== '*')
.map(k => ` ${indent}${propertyDeclaration(k, properties[k])}`)
.join(',\n')}
${indent}}`;
}

Expand Down Expand Up @@ -322,13 +322,13 @@ ${objectDeclaration('TerrainSpecification', spec.terrain)}
${objectDeclaration('ProjectionSpecification', spec.projection)}
${spec.source.map(key => {
let str = objectDeclaration(sourceTypeName(key), spec[key]);
if (sourceTypeName(key) === 'GeoJSONSourceSpecification') {
let str = objectDeclaration(sourceTypeName(key), spec[key]);
if (sourceTypeName(key) === 'GeoJSONSourceSpecification') {
// This is done in order to overcome the type system's inability to express this type:
str = str.replace(/unknown/, 'GeoJSON.GeoJSON | string');
}
return str;
}).join('\n\n')}
str = str.replace(/unknown/, 'GeoJSON.GeoJSON | string');
}
return str;
}).join('\n\n')}
export type SourceSpecification =
${spec.source.map(key => ` | ${sourceTypeName(key)}`).join('\n')}
Expand Down
4 changes: 2 additions & 2 deletions build/release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const regex = /^## (\d+\.\d+\.\d+.*?)\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms;

let releaseNotes = [];
let match;
// eslint-disable-next-line no-cond-assign
while (match = regex.exec(changelog)) {
releaseNotes.push({
'version': match[1],
Expand All @@ -41,5 +41,5 @@ ${latest.changelog}
${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`;

// eslint-disable-next-line eol-last
process.stdout.write(templatedReleaseNotes.trimEnd());
139 changes: 139 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import stylisticTs from '@stylistic/eslint-plugin-ts'
import jsdoc from "eslint-plugin-jsdoc";
import jest from "eslint-plugin-jest";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";


export default [{
ignores: ["build/*.js", "**/dist/*"],
}, {
files: ["**/*.ts"],
plugins: {
"@typescript-eslint": typescriptEslint,
"@stylistic": stylisticTs,
jsdoc,
jest,
},

linterOptions: {
reportUnusedDisableDirectives: true,
},

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
performance: true,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
createDefaultProgram: true,
},
},

settings: {
jsdoc: {
ignorePrivate: true,
},
},

rules: {
"flowtype/require-valid-file-annotation": [0],
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": ["error"],

"@typescript-eslint/no-unused-vars": ["warn", {
argsIgnorePattern: "^_",
}],

"@stylistic/member-delimiter-style": ["error"],
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": ["error"],
"no-undef": "off",
"no-use-before-define": "off",
"implicit-arrow-linebreak": "off",
"arrow-parens": "off",
"arrow-body-style": "off",
"no-confusing-arrow": "off",
"no-control-regex": "off",
"no-invalid-this": "off",
"no-buffer-constructor": "off",
"array-bracket-spacing": "error",
"consistent-return": "off",
"global-require": "off",
"key-spacing": "error",
"no-eq-null": "off",
"no-lonely-if": "off",
"no-new": "off",

"no-restricted-properties": [2, {
object: "Object",
property: "assign",
}],

"no-unused-vars": "off",
"no-warning-comments": "error",
"object-curly-spacing": ["error", "never"],
"prefer-arrow-callback": "error",

"prefer-const": ["error", {
destructuring: "all",
}],

"prefer-template": "error",
quotes: "off",
"@stylistic/quotes": ["error", "single"],
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": ["error"],
"space-before-function-paren": "off",
"template-curly-spacing": "error",
"no-useless-escape": "off",
indent: "off",
"@stylistic/indent": ["error"],

"no-multiple-empty-lines": ["error", {
max: 1,
}],

"jsdoc/check-param-names": "warn",
"jsdoc/require-param": "warn",
"jsdoc/require-param-description": "warn",
"jsdoc/require-param-name": "warn",
"jsdoc/require-returns": "warn",
"jsdoc/require-returns-description": "warn",
"jsdoc/check-alignment": "error",
"jsdoc/check-line-alignment": "error",
"jest/no-commented-out-tests": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/prefer-to-contain": "warn",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"jest/prefer-to-be": "warn",
"jest/no-alias-methods": "warn",
"jest/no-interpolation-in-snapshots": "warn",

"jest/no-large-snapshots": ["warn", {
maxSize: 50,
inlineMaxSize: 20,
}],

"jest/no-deprecated-functions": "warn",
},
}, {
files: ["test/**"],

rules: {
"jsdoc/check-param-names": "off",
"jsdoc/require-param": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-param-name": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off",
},
}];
Loading

0 comments on commit 30d9ad4

Please sign in to comment.