Skip to content

Commit e4dfc83

Browse files
authored
style(parameters): apply standardized formatting (#1463)
* style(parameters): apply standardized formatting * style(parameters): apply standardized formatting
1 parent 430d485 commit e4dfc83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2844
-2175
lines changed

Diff for: packages/parameters/.eslintrc.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
module.exports = {
2+
env: {
3+
browser: false,
4+
es2020: true,
5+
jest: true,
6+
node: true,
7+
},
8+
ignorePatterns: ['coverage', 'lib'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
parser: '@typescript-eslint/parser',
14+
plugins: ['@typescript-eslint', 'prettier'],
15+
settings: {
16+
'import/resolver': {
17+
node: {},
18+
typescript: {
19+
project: './tsconfig.json',
20+
alwaysTryTypes: true,
21+
},
22+
},
23+
},
24+
rules: {
25+
'@typescript-eslint/explicit-function-return-type': [
26+
'error',
27+
{ allowExpressions: true },
28+
], // Enforce return type definitions for functions
29+
'@typescript-eslint/explicit-member-accessibility': 'error', // Enforce explicit accessibility modifiers on class properties and methods (public, private, protected)
30+
'@typescript-eslint/member-ordering': [
31+
// Standardize the order of class members
32+
'error',
33+
{
34+
default: {
35+
memberTypes: [
36+
'signature',
37+
'public-field',
38+
'protected-field',
39+
'private-field',
40+
'constructor',
41+
'public-method',
42+
'protected-method',
43+
'private-method',
44+
],
45+
order: 'alphabetically',
46+
},
47+
},
48+
],
49+
'@typescript-eslint/no-explicit-any': 'error', // Disallow usage of the any type
50+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], // Disallow unused variables, except for variables starting with an underscore
51+
'@typescript-eslint/no-use-before-define': ['off'], // Check if this rule is needed
52+
'no-unused-vars': 'off', // Disable eslint core rule, since it's replaced by @typescript-eslint/no-unused-vars
53+
// Rules from eslint core https://eslint.org/docs/latest/rules/
54+
'array-bracket-spacing': ['error', 'never'], // Disallow spaces inside of array brackets
55+
'computed-property-spacing': ['error', 'never'], // Disallow spaces inside of computed properties
56+
'func-style': ['warn', 'expression'], // Enforce function expressions instead of function declarations
57+
'keyword-spacing': 'error', // Enforce spaces after keywords and before parenthesis, e.g. if (condition) instead of if(condition)
58+
'padding-line-between-statements': [
59+
// Require an empty line before return statements
60+
'error',
61+
{ blankLine: 'always', prev: '*', next: 'return' },
62+
],
63+
'no-console': 0, // Allow console.log statements
64+
'no-multi-spaces': ['error', { ignoreEOLComments: false }], // Disallow multiple spaces except for comments
65+
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], // Enforce no empty line at the beginning & end of files and max 1 empty line between consecutive statements
66+
'no-throw-literal': 'error', // Disallow throwing literals as exceptions, e.g. throw 'error' instead of throw new Error('error')
67+
'object-curly-spacing': ['error', 'always'], // Enforce spaces inside of curly braces in objects
68+
'prefer-arrow-callback': 'error', // Enforce arrow functions instead of anonymous functions for callbacks
69+
quotes: ['error', 'single', { allowTemplateLiterals: true }], // Enforce single quotes except for template strings
70+
semi: ['error', 'always'], // Require semicolons instead of ASI (automatic semicolon insertion) at the end of statements
71+
},
72+
};

Diff for: packages/parameters/jest.config.js

+19-33
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,30 @@ module.exports = {
33
name: 'AWS Lambda Powertools utility: PARAMETERS',
44
color: 'magenta',
55
},
6-
'runner': 'groups',
7-
'preset': 'ts-jest',
8-
'transform': {
6+
runner: 'groups',
7+
preset: 'ts-jest',
8+
transform: {
99
'^.+\\.ts?$': 'ts-jest',
1010
},
11-
moduleFileExtensions: [ 'js', 'ts' ],
12-
'collectCoverageFrom': [
13-
'**/src/**/*.ts',
14-
'!**/node_modules/**',
15-
],
16-
'testMatch': ['**/?(*.)+(spec|test).ts'],
17-
'roots': [
18-
'<rootDir>/src',
19-
'<rootDir>/tests',
20-
],
21-
'testPathIgnorePatterns': [
22-
'/node_modules/',
23-
],
24-
'testEnvironment': 'node',
25-
'coveragePathIgnorePatterns': [
11+
moduleFileExtensions: ['js', 'ts'],
12+
collectCoverageFrom: ['**/src/**/*.ts', '!**/node_modules/**'],
13+
testMatch: ['**/?(*.)+(spec|test).ts'],
14+
roots: ['<rootDir>/src', '<rootDir>/tests'],
15+
testPathIgnorePatterns: ['/node_modules/'],
16+
testEnvironment: 'node',
17+
coveragePathIgnorePatterns: [
2618
'/node_modules/',
2719
'/types/',
2820
'/src/docs.ts', // this file is only used for documentation
2921
],
30-
'coverageThreshold': {
31-
'global': {
32-
'statements': 100,
33-
'branches': 100,
34-
'functions': 100,
35-
'lines': 100,
22+
coverageThreshold: {
23+
global: {
24+
statements: 100,
25+
branches: 100,
26+
functions: 100,
27+
lines: 100,
3628
},
3729
},
38-
'coverageReporters': [
39-
'json-summary',
40-
'text',
41-
'lcov'
42-
],
43-
'setupFiles': [
44-
'<rootDir>/tests/helpers/populateEnvironmentVariables.ts'
45-
]
46-
};
30+
coverageReporters: ['json-summary', 'text', 'lcov'],
31+
setupFiles: ['<rootDir>/tests/helpers/populateEnvironmentVariables.ts'],
32+
};

Diff for: packages/parameters/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
"test:e2e": "jest --group=e2e",
2121
"watch": "jest --watch",
2222
"build": "tsc",
23-
"lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests",
24-
"lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests",
23+
"lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .",
24+
"lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .",
2525
"package": "mkdir -p dist/ && npm pack && mv *.tgz dist/",
2626
"package-bundle": "../../package-bundler.sh parameters-bundle ./dist",
2727
"prepare": "npm run build",
2828
"prepack": "cp ../../.github/scripts/release_patch_package_json.js . && node release_patch_package_json.js",
2929
"postpack": "rm release_patch_package_json.js"
3030
},
3131
"lint-staged": {
32-
"*.ts": "npm run lint-fix"
32+
"*.ts": "npm run lint-fix",
33+
"*.js": "npm run lint-fix"
3334
},
3435
"homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/parameters#readme",
3536
"license": "MIT-0",
@@ -68,4 +69,4 @@
6869
"@aws-lambda-powertools/commons": "^1.8.0",
6970
"@aws-sdk/util-base64-node": "^3.209.0"
7071
}
71-
}
72+
}

0 commit comments

Comments
 (0)