Skip to content

Commit

Permalink
style: add additional style rules & apply fixes (#75)
Browse files Browse the repository at this point in the history
* style: add `object-shorthand` rule & apply fixes
* chore: update ts-eslint plugin & parser
* style: add ts-eslint `key-spacing` rule & apply fixes
* style: add ts-eslint `space-before-blocks` rule
* style: add `arrow-spacing` rule
* style: add `arrow-parens` rule & apply fixes
* style: add ts-eslint `brace-style` rule
* style: add ts-eslint `member-delimiter-style` rule
* style: add `array-bracket-newline` rule
* style: add `object-curly-newline` rule
* style: add `padded-blocks` rule & apply fixes
* style: add `eslint-plugin-import/exports-last` rule & apply fixes
* style: add ts-eslint `indent` rule
* style: add `'no-unused-vars': 'off'` as per ts-eslint docs
* style: switch to ts-eslint's `semi` rule & apply fixes
* style: organize eslintrc
* style: add `padding-line-between-statements` rule for directives
* style: remove ignores/overrides and apply style fixes
* style: add ts-eslint `keyword-spacing` rule
* style: add ts-eslint `space-infix-ops` rule
* style: switch to ts-eslint `object-curly-spacing` & apply fixes
* style: switch to ts-eslint `comma-dangle`
* style: switch to ts-eslint `padding-line-between-statements`
* merge: latest from main
* style: apply style fixes
  • Loading branch information
devonzara committed Apr 4, 2023
1 parent 9ceca1d commit e4a5f28
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 150 deletions.
62 changes: 47 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,52 @@ module.exports = {
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
ignorePatterns: ['.github', 'server/migrations', 'dist'],
ignorePatterns: ['.github', 'dist'],
root: true,
env: {
node: true,
},
rules: {
// Disable base rules to avoid @typescript-eslint conflicts
'brace-style': 'off',
'comma-dangle': 'off',
indent: 'off',
'key-spacing': 'off',
'keyword-spacing': 'off',
'no-unused-vars': 'off',
'object-curly-spacing': 'off',
'padding-line-between-statements': 'off',
semi: 'off',
'space-before-blocks': 'off',
'space-infix-ops': 'off',

// Basic rules
indent: ['error', 2, { SwitchCase: 1 }],
// `ts-lint: indent` has known issues, we can remove if it becomes a problem...
// https://github.com/typescript-eslint/typescript-eslint/issues/1824
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
flatTernaryExpressions: false,
ignoredNodes: [
'PropertyDefinition[decorators]',
'TSUnionType',
'FunctionExpression[params]:has(Identifier[decorators])',
],
}],
'max-len': ['warn', 120],
'@typescript-eslint/no-unused-vars': 'error',
'prefer-const': 'error',
semi: ['error', 'always'],
'@typescript-eslint/semi': 'error',

// Quote rules
quotes: ['error', 'single'],
'quote-props': ['error', 'as-needed'],

// TypeScript rules
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'error',

// Comma rules
'comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': ['error', 'last'],

Expand All @@ -36,19 +60,34 @@ module.exports = {
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
'no-trailing-spaces': 'error',

// Keyword/operator spacing rules
'@typescript-eslint/keyword-spacing': 'error',
'@typescript-eslint/space-infix-ops': 'error',

// Brace/parenthesis spacing rules
'array-bracket-spacing': ['error', 'never'],
'object-curly-spacing': ['error', 'always', { objectsInObjects: false }],
'array-bracket-newline': ['error', 'consistent'],
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': 'error',
'@typescript-eslint/brace-style': 'error',
'@typescript-eslint/key-spacing': 'error',
'object-curly-newline': ['error', { consistent: true }],
'@typescript-eslint/object-curly-spacing': ['error', 'always', { objectsInObjects: false }],
'object-shorthand': ['error', 'always', { avoidQuotes: true }],
'padded-blocks': ['error', 'never'],
'@typescript-eslint/space-before-blocks': 'error',
'space-in-parens': ['error', 'never'],

// Newline padding rules
'padding-line-between-statements': [
'@typescript-eslint/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'export' },
{ blankLine: 'any', prev: 'export', next: 'export' },
{ blankLine: 'always', prev: 'directive', next: '*' },
],

// Import rules
// Import/export rules
'import/exports-last': 'error',
'import/newline-after-import': 'error',
'import/order': ['error', {
groups: [
Expand All @@ -64,12 +103,6 @@ module.exports = {
alphabetize: { order: 'asc', caseInsensitive: true },
}],
},
overrides: [{
files: ['server/migrations/*.js'],
rules: {
'@typescript-eslint/no-unused-vars': 0,
},
}],
settings: {
'import/resolver': {
typescript: true,
Expand All @@ -80,4 +113,3 @@ module.exports = {
},
},
};

4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
supportFile: './cypress/support/e2e.ts',
specPattern:'./cypress/e2e',
specPattern: './cypress/e2e',
},
fixturesFolder: './cypress/fixtures',
screenshotsFolder: './cypress/screenshots',
videosFolder: './cypress/videos',
downloadsFolder: './cypress/downloads',
fileServerFolder:'./',
fileServerFolder: './',
});
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
// }
// }
// }
export = {}
export = {};

0 comments on commit e4a5f28

Please sign in to comment.