Skip to content

Commit

Permalink
Merge pull request #912 from intuitem/sec/secure-redirect-linting-rule
Browse files Browse the repository at this point in the history
Write secure-redirect eslint rule
  • Loading branch information
Mohamed-Hacene authored Oct 15, 2024
2 parents c19a57a + d3b8f40 commit 180a561
Show file tree
Hide file tree
Showing 13 changed files with 1,047 additions and 13,801 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/frontend-linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
- name: Install latest pnpm
working-directory: ${{env.working-directory}}
run: |
npm install -g pnpm &&
npm --version &&
npm list -g --depth 0
pnpm --version &&
pnpm list -g --depth 0
- name: Install prettier
working-directory: ${{env.working-directory}}
run: pnpm add --save-dev prettier
Expand Down
15 changes: 0 additions & 15 deletions frontend/.eslintignore

This file was deleted.

5 changes: 4 additions & 1 deletion frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ module.exports = {
'plugin:storybook/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'eslint-plugin-intuitem-sveltekit'],
rules: {
'eslint-plugin-intuitem-sveltekit/secure-redirect': 'error'
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
Expand Down
1 change: 1 addition & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules
!.env.example
/tests/reports/*
/tests/results/*
**/paraglide

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
Expand Down
82 changes: 82 additions & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import intuitemSveltekit from './plugins/eslint/eslint-plugin-intuitem-sveltekit/index.js';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import parser from 'svelte-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 [
{
ignores: [
'**/.DS_Store',
'**/node_modules',
'build',
'.svelte-kit',
'package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'tests/reports/*',
'tests/results/*',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock'
]
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier',
'plugin:storybook/recommended'
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
'eslint-plugin-intuitem-sveltekit': intuitemSveltekit
},

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

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

parserOptions: {
extraFileExtensions: ['.svelte']
}
},

rules: {
'eslint-plugin-intuitem-sveltekit/secure-redirect': 'error'
}
},
{
files: ['**/*.svelte'],

languageOptions: {
parser: parser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
parser: '@typescript-eslint/parser'
}
}
}
];
Loading

0 comments on commit 180a561

Please sign in to comment.