Skip to content

Commit

Permalink
style: stylistic
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerCodeMonkey committed Sep 13, 2024
1 parent a27072d commit b2969cd
Show file tree
Hide file tree
Showing 20 changed files with 3,471 additions and 5,170 deletions.
47 changes: 0 additions & 47 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"angular.ng-template",
"EditorConfig.EditorConfig"
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "**/.github/workflows/*.yml"
},
"angular.forceStrictTemplates": true,
"prettier.enable": false
}
30 changes: 0 additions & 30 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@
"tsConfig": "projects/angular-stl-model-viewer/tsconfig.spec.json",
"karmaConfig": "projects/angular-stl-model-viewer/karma.conf.js"
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"projects/angular-stl-model-viewer/**/*.ts",
"projects/angular-stl-model-viewer/**/*.html"
]
}
}
}
},
Expand Down Expand Up @@ -127,27 +118,6 @@
],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"projects/examples/**/*.ts",
"projects/examples/**/*.html"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "projects/examples/e2e/protractor.conf.js",
"devServerTarget": "examples:serve"
},
"configurations": {
"production": {
"devServerTarget": "examples:serve:production"
}
}
}
}
}
Expand Down
257 changes: 257 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
// @ts-check
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

import js from '@eslint/js'
import json from '@eslint/json'
import stylistic from '@stylistic/eslint-plugin'
import angular from 'angular-eslint'
import globals from 'globals'
import tseslint from 'typescript-eslint'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

export default tseslint.config(
{
name: 'ignores',
ignores: [
'/**/node_modules/*',
'node_modules/',
'dist/',
'.nx/',
'.angular/',
'coverage/'
]
},

{
name: 'lib tsc options',
files: ['projects/angular-stl-model-viewer/**/*.{ts,mts,tsx}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: ['tsconfig.lib.json', 'tsconfig.spec.json'],
tsconfigRootDir: 'projects/angular-stl-model-viewer'
}
}
},
{
name: 'examples tsc options',
files: ['projects/examples/**/*.{ts,mts,tsx}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: ['tsconfig.app.json', 'tsconfig.spec.json'],
tsconfigRootDir: 'projects/examples'
}
}
},
{
name: 'angular ts recommended rules',
files: ['projects/angular-stl-model-viewer/**/*.{ts,mts,tsx}', 'projects/examples/**/*.{ts,mts,tsx}'],
plugins: {
'@stylistic': stylistic
},
extends: [...tseslint.configs.recommended, ...tseslint.configs.stylistic, ...angular.configs.tsRecommended, stylistic.configs['recommended-flat']],
rules: {
'@angular-eslint/no-output-on-prefix': 'off',
'@angular-eslint/component-class-suffix': [
'off',
{
type: 'element',
prefix: 'lib',
style: 'kebab-case'
}
],
'@angular-eslint/component-selector': [
'off',
{
type: 'element',
prefix: 'lib',
style: 'kebab-case'
}
],
'@angular-eslint/directive-selector': [
'off',
{
type: 'attribute',
prefix: 'lib',
style: 'camelCase'
}
],

'@stylistic/no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 0,
maxEOF: 1
}
],
'@stylistic/semi': ['error', 'never'],
'@stylistic/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
requireLast: true
},
singleline: {
delimiter: 'semi',
requireLast: false
},
multilineDetection: 'brackets'
}
],
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/object-property-newline': ['error'],
'@stylistic/object-curly-newline': ['error'],
'@stylistic/object-curly-spacing': ['error', 'always'],

'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-empty-function': ['warn']
}
},
{
name: 'Angular template recommended rules',
files: ['projects/angular-stl-model-viewer/**/*.html', 'projects/examples/**/*.html'],
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
rules: {
'@angular-eslint/template/no-negated-async': 'off',
'@angular-eslint/template/click-events-have-key-events': ['warn'],
'@angular-eslint/template/interactive-supports-focus': ['warn']
}
},

// root files
{
name: 'Root files tsc options',
files: ['*.{ts,tsx,mts}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: ['tsconfig.json'],
tsconfigRootDir: __dirname
}
}
},
{
name: 'Scripts stylistic ts recommended rules',
files: ['*.{ts,tsx,mts}'],
plugins: {
'@stylistic': stylistic
},
extends: [...tseslint.configs.recommended, ...tseslint.configs.stylistic, stylistic.configs['recommended-flat']],
rules: {
'@stylistic/no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 0,
maxEOF: 1
}
],
'@stylistic/semi': ['error', 'never'],
'@stylistic/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
requireLast: true
},
singleline: {
delimiter: 'semi',
requireLast: false
},
multilineDetection: 'brackets'
}
],
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/object-property-newline': ['error'],
'@stylistic/object-curly-newline': ['error'],
'@stylistic/object-curly-spacing': ['error', 'always'],

'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-empty-function': ['warn']
}
},

{
name: 'JS',
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
plugins: {
js,
'@stylistic': stylistic
},
extends: [js.configs.recommended, stylistic.configs['recommended-flat']],
languageOptions: {
globals: {
...globals.node,
document: false
}
},
rules: {
'@stylistic/no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 0,
maxEOF: 1
}
],
'@stylistic/semi': ['error', 'never'],
'@stylistic/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
requireLast: true
},
singleline: {
delimiter: 'semi',
requireLast: false
},
multilineDetection: 'brackets'
}
],
'@stylistic/comma-dangle': ['error', 'never']
}
},

// lint JSON files
{
files: ['**/*.json'],
plugins: {
json,
'@stylistic': stylistic
},
ignores: ['package-lock.json'],
language: 'json/json',
extends: [json.configs.recommended]
},

// lint JSONC files
{
files: ['**/*.jsonc'],
plugins: {
json,
'@stylistic': stylistic
},
language: 'json/jsonc',
extends: [json.configs.recommended]
},

// lint JSON5 files
{
files: ['**/*.json5'],
plugins: {
json,
'@stylistic': stylistic
},
language: 'json/json5',
extends: [json.configs.recommended]
}
)
Loading

0 comments on commit b2969cd

Please sign in to comment.