Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8147 - Upgrade to ESLint 9 #3411

Merged
merged 39 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cad719d
change eslintrc format to flat config
NFriedo Sep 27, 2024
1bba003
remove .eslintignore, move it to the ignores object
NFriedo Sep 27, 2024
cbe4bbf
correct ignores
NFriedo Sep 27, 2024
f852dda
try out flatcompat for package that does not support flat config
NFriedo Sep 27, 2024
78b8e65
try out flatcompat for package that does not support flat config
NFriedo Sep 27, 2024
f59ca33
adjust custom plugin accordingly
NFriedo Sep 27, 2024
13f888e
change to flat config in eslint webpack plugin
NFriedo Sep 27, 2024
36f7051
Merge branch 'main' into BC-8147-eslint-flat-config
NFriedo Sep 27, 2024
3ec3885
upgrade to eslint9
NFriedo Oct 7, 2024
6399785
fix eslint errors
NFriedo Oct 7, 2024
ab7eeeb
add comment for no-require-imports rule
NFriedo Oct 7, 2024
53e5fc2
remove not needed compat eslintrc package
NFriedo Oct 7, 2024
f6acc64
fix custom rule test
NFriedo Oct 7, 2024
eeb21f4
Merge branch 'main' into BC-8147-eslint-flat-config
NFriedo Oct 7, 2024
728ee36
remove comment
NFriedo Oct 7, 2024
87040b5
fix eslint errors
NFriedo Oct 7, 2024
009d270
Merge branch 'main' into BC-8147-eslint-flat-config
NFriedo Oct 23, 2024
ecfecdd
update typescript-eslint to support newer ts version, update eslint-c…
NFriedo Oct 23, 2024
2047262
sort rules alphabetically
NFriedo Oct 23, 2024
141ba55
update eslint
NFriedo Oct 23, 2024
c1bc7da
move ignores to global to match directories
NFriedo Oct 24, 2024
b7472c5
remove not needed eslint-disable comments
NFriedo Oct 24, 2024
1feba8b
Merge remote-tracking branch 'origin/main' into BC-8147-eslint-flat-c…
NFriedo Oct 24, 2024
ea5081d
update package-lock.json
NFriedo Oct 24, 2024
740e9ee
adjust rules, exclude config from sonarcloud coverage
NFriedo Oct 25, 2024
d5b805d
move mock-store-module to test folder
NFriedo Oct 25, 2024
dae5008
Merge branch 'main' into BC-8147-eslint-flat-config
NFriedo Oct 25, 2024
4155010
update versions
NFriedo Oct 25, 2024
c43766d
exclude eslint config from sonarcloud report
NFriedo Oct 25, 2024
27c21de
try out exluding eslint from sonarcloud
NFriedo Oct 25, 2024
ac7b29b
Revert "try out exluding eslint from sonarcloud"
NFriedo Oct 25, 2024
8496e72
try out excluding eslint from sonarcloud
NFriedo Oct 25, 2024
c707186
Revert "try out excluding eslint from sonarcloud"
NFriedo Oct 25, 2024
e8c908a
review adjustments
NFriedo Oct 25, 2024
96baefb
remove not needed ecma version
NFriedo Oct 25, 2024
fdf9bb4
Merge remote-tracking branch 'origin/main' into BC-8147-eslint-flat-c…
NFriedo Oct 25, 2024
b7a795a
exclude eslint config from coverage
NFriedo Oct 28, 2024
e708573
BC-8147 - refactor SonarCloud configuration and github action
SevenWaysDP Oct 28, 2024
a20f085
add tests folder to coverage exclusions
NFriedo Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

104 changes: 0 additions & 104 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ RUN apt update && apt install -y g++ libcairo2-dev libpango1.0-dev libjpeg-dev l
WORKDIR /app

COPY package.json package-lock.json ./
COPY lib/eslint-plugin-schulcloud ./lib/eslint-plugin-schulcloud
RUN npm ci

COPY babel.config.js .eslintrc.js LICENSE.md .prettierrc.js tsconfig.json tsconfig.build.json .eslintignore .prettierignore ./
COPY babel.config.js eslint.config.js LICENSE.md .prettierrc.js tsconfig.json tsconfig.build.json .prettierignore ./
COPY lib/eslint-plugin-schulcloud ./lib/eslint-plugin-schulcloud
COPY public ./public
COPY src ./src
COPY config/webpack ./config/webpack
Expand Down
1 change: 1 addition & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module.exports = {
extensions: [".js", ".jsx", ".vue", ".ts", ".tsx"],
failOnWarning: false,
failOnError: true,
configType: "flat",
}),
],

Expand Down
142 changes: 142 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
const js = require("@eslint/js");
const pluginVue = require("eslint-plugin-vue");
const vueTsEslintConfig = require("@vue/eslint-config-typescript");
const schulcloud = require("./lib/eslint-plugin-schulcloud");
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");
const globals = require("globals");

module.exports = [
...pluginVue.configs["flat/essential"],
js.configs.recommended,
...vueTsEslintConfig({
extends: ["recommended"],
supportedScriptLangs: {
ts: true,

// [!DISCOURAGED]
// Set to `true` to allow plain `<script>` or `<script setup>` blocks.
// This might result-in false positive or negatives in some rules for `.vue` files.
// Note you also need to configure `allowJs: true` and `checkJs: true`
// in corresponding `tsconfig.json` files.
js: true,
},
}),
eslintPluginPrettierRecommended,

{
ignores: [
".vscode/**",
"node_modules/**",
"**/dist/**",
"src/serverApi/**",
"src/fileStorageApi/**",
"src/h5pEditorApi/**",
],
},
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.node,
},
},
plugins: {
schulcloud,
},
rules: {
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-object-type": [
"error",
{ allowInterfaces: "with-single-extends" },
],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-restricted-imports": [
"warn",
{
patterns: [
{
group: [
"@data-*/*",
"@feature-*/*",
"@page-*/*",
"@ui-*/*",
"@util-*/*",
],
message: "Do not deep import into a module",
},
{
group: ["@/modules/data/*", "*/../data/*", "../**/data/*"],
message:
"Data-Modules have to be imported using the pattern '@data-<name>'",
},
{
group: [
"@/modules/feature/*",
"*/../feature/*",
"../**/feature/*",
],
message:
"Feature-Modules have to be imported using the pattern '@feature-<name>'",
},
{
group: ["@/modules/page/*", "*/../page/*", "../**/page/*/*"],
message:
"Page-Modules have to be imported using the pattern '@page-<name>'",
},
{
group: ["@/modules/ui/*", "*/../ui/*", "../**/ui/*/*"],
message:
"Ui-Modules have to be imported using the pattern '@ui-<name>'",
},
{
group: ["@/modules/util/*", "*/../util/*", "../**/util/*/*"],
message:
"Util-Modules have to be imported using the pattern '@util-<name>'",
},
],
},
],
"@typescript-eslint/no-unused-vars": "warn",
"no-console": process.env.NODE_ENV === "production" ? "off" : "warn",
"no-debugger": process.env.NODE_ENV === "production" ? "off" : "warn",
"no-empty": "error",
"no-irregular-whitespace": "error",
"no-prototype-builtins": "error",
"no-undef": "warn",
"no-unused-vars": "off", // disable the base rule for @typescript-eslint/no-unused-vars
"no-useless-escape": "error",
"no-var": "error",
"prefer-const": "error",
"prettier/prettier": "error",
"schulcloud/material-icon-imports": "error",
"vue/html-self-closing": [
"error",
{
html: {
void: "always",
},
},
],
"vue/multi-word-component-names": "off", // TODO - make a final decision about this rule
"vue/no-mutating-props": "error",
"vue/no-setup-props-reactivity-loss": "error",
"vue/no-useless-template-attributes": "error",
"vue/no-v-html": "error",
"vue/no-v-text-v-html-on-component": "error",
},
},
{
files: ["**/*.unit.{j,t}s?(x)", "tests/**"],
languageOptions: {
globals: {
...globals.jest,
mount: "readonly",
shallowMount: "readonly",
fail: "readonly",
},
},
},
];
11 changes: 8 additions & 3 deletions lib/eslint-plugin-schulcloud/material-icon-imports.unit.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
"use strict";

const { RuleTester } = require("eslint");
const rule = require("./material-icon-imports.js");
const materialIconImportRule = require("./material-icon-imports.js");

global.structuredClone = (value) => {
return JSON.parse(JSON.stringify(value));
};
const ruleTester = new RuleTester({
parserOptions: { ecmaVersion: 2020, sourceType: "module" },
languageOptions: {
ecmaVersion: 2020,
},
});

ruleTester.run("material-icon-imports", rule, {
ruleTester.run("material-icon-imports", materialIconImportRule, {
valid: [
{
code: `import { mdiCheck } from "@icons/material";`,
Expand Down
Loading
Loading