Skip to content

Commit

Permalink
refactor: eslint update to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
alecarn authored Sep 17, 2024
1 parent 0d180dd commit 0285a06
Show file tree
Hide file tree
Showing 24 changed files with 507 additions and 851 deletions.
56 changes: 0 additions & 56 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"],
"eslintConfig": "eslint.config.js"
}
},
"e2e": {
Expand Down Expand Up @@ -367,7 +368,6 @@
},
"cli": {
"schematicCollections": [
"@angular-eslint/schematics",
"@schematics/angular"
],
"analytics": false
Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
baseUrl: 'http://localhost:4201',
specPattern: 'e2e/src/*.spec.ts',
supportFile: 'e2e/support/e2e.ts',
videosFolder: "e2e/dist/videos",
screenshotsFolder: "e2e/dist/screenshots",
videosFolder: 'e2e/dist/videos',
screenshotsFolder: 'e2e/dist/screenshots'
}
});
5 changes: 2 additions & 3 deletions e2e/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
"name": "Using fixtures to represent data",
"email": "[email protected]"
}

11 changes: 4 additions & 7 deletions e2e/src/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ describe('My First Test', () => {
const url = 'http://localhost:4201';
it('Check the config file', () => {
cy.visit('/');
cy.request('GET', `${url}/config/config.json`).then(
(response) => {
expect(response.body).to.have.property('title', 'IGO'); // true
expect(response.body).to.have.property('theme', 'blue-theme'); // true
}
);
cy.request('GET', `${url}/config/config.json`).then((response) => {
expect(response.body).to.have.property('title', 'IGO'); // true
expect(response.body).to.have.property('theme', 'blue-theme'); // true
});
});

});
10 changes: 5 additions & 5 deletions e2e/support/component-index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
</html>
9 changes: 4 additions & 5 deletions e2e/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

import { mount } from 'cypress/angular';

import './commands';

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
mount: typeof mount
mount: typeof mount;
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"types":[
"jasmine",
"jasminewd2",
"node"
]
"types": ["jasmine", "jasminewd2", "node"]
}
}
74 changes: 74 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// @ts-check
const stylistic = require('@stylistic/eslint-plugin');
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const angular = require('angular-eslint');

module.exports = tseslint.config(
{
files: ['**/*.ts'],
plugins: {
// @ts-ignore
'@stylistic': stylistic
},
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended
],
processor: angular.processInlineTemplates,
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'app',
style: 'camelCase'
}
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'app',
style: 'kebab-case'
}
],
'@angular-eslint/no-output-native': 'off',
'@stylistic/semi': ['error', 'always'],
'@typescript-eslint/array-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-expressions': [
'error',
{ allowTernary: true }
],
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used', destructuredArrayIgnorePattern: '^_' }
],
'arrow-spacing': 'error',
eqeqeq: ['error', 'smart'],
'no-multi-spaces': 'error',
'no-multiple-empty-lines': 'error',
'no-trailing-spaces': 'error',
'no-useless-escape': 'warn',

'no-unused-vars': 'off',
semi: 'warn',
'semi-spacing': 'warn'
}
},
{
files: ['**/*.html'],
extends: [
...angular.configs.templateRecommended,
...angular.configs.templateAccessibility
],
rules: {
'@angular-eslint/template/alt-text': 'warn',
'@angular-eslint/template/click-events-have-key-events': 'warn',
'@angular-eslint/template/interactive-supports-focus': 'warn'
}
}
);
Loading

0 comments on commit 0285a06

Please sign in to comment.