Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

42 changes: 0 additions & 42 deletions .eslintrc.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .gitignore:
node_modules/
dist/
cypress/videos
cypress/screenshots
.DS_Store
.env

#legacy
i18n-scripts/
#generated
package-lock.json
locales/
# YAML files
*.yaml
*.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ nmstate-console-plugin development require web development tools, and a kubernet
| -------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [nodejs](https://nodejs.org/) | JavaScript runtime environment |
| [npm](https://www.npmjs.com/) | package manager for nodejs (comes with nodejs) |
| [kubernetes]() | An [Openshift](<(https://www.openshift.com/)>) or kubernetes cluster for development |
| [kubernetes](<>) | An [Openshift](<(https://www.openshift.com/)>) or kubernetes cluster for development |
| [kubectl](https://kubernetes.io/docs/tasks/tools/) | The Kubernetes command-line tool |

### Spin your own small kubernetes
Expand Down
21 changes: 11 additions & 10 deletions cypress/e2e/NewPolicy.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const deletePolicyFromDetailsPage = (policyName: string) => {

cy.contains('button[disabled]', 'Delete');

cy.get('input#text-confirmation').clear().type(`${policyName}`);
cy.get('input#text-confirmation').clear();
cy.get('input#text-confirmation').type(`${policyName}`);

cy.contains('button', 'Delete').click();

Expand All @@ -26,17 +27,16 @@ describe('Create new policy with form', () => {
cy.contains('button', 'From Form').click();

// Network identity step
cy.wait(1000);
cy.get('input[name="physical-network-name"]').clear().type(`${testPolicyName}`);
cy.get('input[name="physical-network-name"]').should('be.visible').clear();
cy.get('input[name="physical-network-name"]').type(`${testPolicyName}`);
cy.contains('button', 'Next').click();

// Nodes configuration step
cy.get('input[name="policy-name"]')
.should('be.visible')
.click()
.type('{selectall}{backspace}')
.type(testPolicyName);
cy.get('input[name="policy-description"]').clear().type(`${testDescription}`);
cy.get('input[name="policy-name"]').should('be.visible').click();
cy.get('input[name="policy-name"]').type('{selectall}{backspace}');
cy.get('input[name="policy-name"]').type(testPolicyName);
cy.get('input[name="policy-description"]').clear();
cy.get('input[name="policy-description"]').type(`${testDescription}`);
cy.contains('button', 'Next').click();

// Uplink connection step - 'Default node network' selected by default
Expand All @@ -49,7 +49,8 @@ describe('Create new policy with form', () => {
cy.byLegacyTestID('review-network-description').should('have.text', testDescription);
cy.contains('button', 'Create network').click();

cy.contains('h1', testPolicyName);
cy.visit('/k8s/cluster/nmstate.io~v1~NodeNetworkConfigurationPolicy');
cy.contains('a', testPolicyName).should('be.visible').click();

deletePolicyFromDetailsPage(testPolicyName);
});
Expand Down
1 change: 0 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-namespace */
/// <reference types="cypress" />
import { KUBEADMIN_IDP, KUBEADMIN_USERNAME } from './constants';
import { ConsoleWindowType } from './types';
Expand Down
121 changes: 121 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import prettierConfig from 'eslint-config-prettier';
import cypressPlugin from 'eslint-plugin-cypress';
import importPlugin from 'eslint-plugin-import';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import tseslint from 'typescript-eslint';

import js from '@eslint/js';

export default tseslint.config(
{
ignores: [
// .gitignore:
'**/node_modules/',
'**/dist/',
'cypress/videos',
'cypress/screenshots',
'**/.DS_Store',
'.env',
// legacy
'i18n-scripts/',
// generated
'package-lock.json',
'locales/',
],
},

js.configs.recommended,
...tseslint.configs.recommended,
reactPlugin.configs.flat.recommended,

{
languageOptions: {
globals: {
...globals.browser,
...globals.es2021,
},
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
plugins: {
import: importPlugin,
'react-hooks': reactHooksPlugin,
'simple-import-sort': simpleImportSort,
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_' }],

'import/no-cycle': 'off',
'import/no-duplicates': 'error',

'no-console': 'error',
'no-nested-ternary': 'error',

'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react/display-name': 'off',
'react/prop-types': 'off',

'simple-import-sort/exports': 'error',
'simple-import-sort/imports': [
'warn',
{
groups: [
[
'^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)',
],
['^react', '^\\w'],
['^(@|config/)(/*|$)'],
['^\\u0000'],
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
['^.+\\.s?css$'],
],
},
],
},
settings: {
react: { version: 'detect' },
},
},

{
files: ['**/*.{js,cjs}', 'webpack.config.ts', 'jest.config.ts', 'cypress.config.ts'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},

{
files: ['cypress/**/*.{js,ts,jsx,tsx}'],
...cypressPlugin.configs.recommended,
languageOptions: {
globals: {
...globals.node,
...cypressPlugin.configs.globals.languageOptions.globals,
},
},
rules: {
...cypressPlugin.configs.recommended.rules,
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-require-imports': 'off',
'no-console': 'off',
'no-redeclare': 'off',
},
},

// last to disable conflicting rules
prettierConfig,
);
2 changes: 0 additions & 2 deletions i18next-parser.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef
const { CustomJSONLexer } = require('./i18n-scripts/lexers');

// eslint-disable-next-line no-undef
module.exports = {
createOldCatalogs: false,
defaultNamespace: 'plugin__nmstate-console-plugin',
Expand Down
15 changes: 7 additions & 8 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { pathsToModuleNameMapper } from 'ts-jest';
import { readConfigFile, sys } from 'typescript';

import type { Config } from '@jest/types';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { compilerOptions } = require('./tsconfig');
const { config: tsconfig } = readConfigFile('./tsconfig.json', sys.readFile);
const { compilerOptions } = tsconfig;

// Sync object
const config: Config.InitialOptions = {
Expand All @@ -22,13 +23,11 @@ const config: Config.InitialOptions = {
modulePaths: ['<rootDir>'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
transform: {
'^.+\\.[t|j]sx?$': 'ts-jest',
'^.+\\.[t|j]sx?$': [
'ts-jest',
{ tsconfig: { ...compilerOptions, module: 'commonjs', moduleResolution: 'node' } },
],
},
transformIgnorePatterns: ['<rootDir>/node_modules/(?!(@patternfly|@openshift-console\\S*?)/.*)'],
globals: {
'ts-jest': {
isolatedModules: true,
},
},
};
export default config;
Loading
Loading