Skip to content

Commit 997a85b

Browse files
committed
Install dependencies, add configs
1 parent ce98235 commit 997a85b

24 files changed

+2353
-184
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44

55
root = true
66

7+
78
[*]
89
end_of_line = lf
910
charset = utf-8
1011
trim_trailing_whitespace = true
1112
insert_final_newline = true
1213
indent_style = space
1314
indent_size = 2
15+
max_line_length = 100
1416

1517
[*.hbs]
16-
insert_final_newline = false
1718

1819
[*.{diff,md}]
1920
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
# dependencies
1010
/bower_components/
11-
/node_modules/
1211

1312
# misc
1413
/coverage/
15-
!.*
1614

1715
# ember-try
1816
/.node_modules.ember-try/
1917
/bower.json.ember-try
2018
/package.json.ember-try
19+
20+
# IDE
21+
/.idea/
22+
/.history/

.eslintrc.js

Lines changed: 101 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,127 @@
11
'use strict';
22

3+
const nodeFiles = [
4+
'.eslintrc.js',
5+
'.lintstagedrc.js',
6+
'.prettierrc.js',
7+
'.template-lintrc.{js,ts}',
8+
'ember-cli-build.{js,ts}',
9+
'testem.{js,ts}',
10+
'blueprints/*/index.{js,ts}',
11+
'config/**/*.{js,ts}',
12+
'lib/*/index.{js,ts}',
13+
'server/**/*.{js,ts}',
14+
];
15+
16+
const browserFiles = [
17+
'addon/**/*.{js,ts}',
18+
'addon-test-support/**/*.{js,ts}',
19+
'app/**/*.{js,ts}',
20+
'test-support/**/*.{js,ts}',
21+
'types/**/*.{js,ts}',
22+
];
23+
24+
const browserTestFiles = ['tests/**/*.{js,ts}'];
25+
326
module.exports = {
427
root: true,
5-
parser: 'babel-eslint',
28+
parser: '@typescript-eslint/parser',
629
parserOptions: {
730
ecmaVersion: 2018,
831
sourceType: 'module',
9-
ecmaFeatures: {
10-
legacyDecorators: true
11-
}
32+
project: ['./tsconfig.json', './tsconfig-node.json'],
1233
},
13-
plugins: [
14-
'ember'
15-
],
34+
plugins: ['@typescript-eslint', 'ember', 'prettier'],
1635
extends: [
1736
'eslint:recommended',
18-
'plugin:ember/recommended'
37+
'plugin:@typescript-eslint/eslint-recommended',
38+
'plugin:@typescript-eslint/recommended',
39+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
40+
'plugin:ember/recommended',
41+
'standard',
42+
43+
'prettier/@typescript-eslint',
44+
'prettier/standard',
45+
46+
// This one should come last
47+
'plugin:prettier/recommended',
1948
],
2049
env: {
21-
browser: true
50+
browser: true,
2251
},
2352
rules: {
24-
'ember/no-jquery': 'error'
53+
'@typescript-eslint/ban-ts-ignore': 'off', // Can't fully get rid of it due to TS quirks and issues with third-party depenecies
54+
'@typescript-eslint/camelcase': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args
55+
'@typescript-eslint/class-name-casing': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args
56+
'@typescript-eslint/no-empty-function': 'off', // Noop is a valid technique.
57+
'@typescript-eslint/no-empty-interface': 'off', // Required for simplified typing of Mirage and Ember Data
58+
'@typescript-eslint/no-non-null-assertion': 'off', // When I do it, I mean it.
59+
'@typescript-eslint/no-unsafe-assignment': 'off', // Reenabled for TS files only
60+
'@typescript-eslint/no-unsafe-call': 'off', // Reenabled for TS files only
61+
'@typescript-eslint/no-unsafe-member-access': 'off', // Reenabled for TS files only
62+
'@typescript-eslint/no-unsafe-return': 'off', // Reenabled for TS files only
63+
'@typescript-eslint/no-unused-expressions': 'off', // Reenabled for non-tests only (Chai needs this disabled)
64+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
65+
'@typescript-eslint/no-var-requires': 'off', // Reenabled for non-Node files only
66+
67+
// As this rule would freak out on JS files (by design!),
68+
// it has to be enabled only for .ts in the overrides section,
69+
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#configuring-in-a-mixed-jsts-codebase
70+
'@typescript-eslint/explicit-function-return-type': 'off',
71+
72+
camelcase: 'off', // Have to keep this off for the TS equivalent to take precedence
73+
'no-console': ['error', { allow: ['debug', 'error', 'info', 'warn'] }],
74+
'no-unused-expressions': 'off',
75+
'no-useless-constructor': 'off', // This rule crashes ESLint unless disabled
76+
77+
'node/no-unpublished-require': 'off', // Reenabled for non-Node files only
78+
79+
'prefer-const': 'error', // Only use `let` when you are actually mutating the variable
80+
'prettier/prettier': 'error',
2581
},
2682
overrides: [
2783
// node files
2884
{
29-
files: [
30-
'.eslintrc.js',
31-
'.template-lintrc.js',
32-
'ember-cli-build.js',
33-
'index.js',
34-
'testem.js',
35-
'blueprints/*/index.js',
36-
'config/**/*.js',
37-
'tests/dummy/config/**/*.js'
38-
],
39-
excludedFiles: [
40-
'addon/**',
41-
'addon-test-support/**',
42-
'app/**',
43-
'tests/dummy/app/**'
44-
],
85+
files: nodeFiles,
4586
parserOptions: {
46-
sourceType: 'script'
87+
sourceType: 'script',
4788
},
4889
env: {
4990
browser: false,
50-
node: true
91+
node: true,
5192
},
5293
plugins: ['node'],
53-
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
94+
rules: {
95+
...require('eslint-plugin-node').configs.recommended.rules, // eslint-disable-line node/no-unpublished-require
5496
// add your custom rules and overrides for node files here
55-
})
56-
}
57-
]
97+
'node/no-unsupported-features/es-syntax': ['error', { version: '>=12.0.0' }],
98+
},
99+
},
100+
{
101+
// browser files, including tests
102+
files: [...browserFiles, ...browserTestFiles],
103+
rules: {
104+
'@typescript-eslint/no-var-requires': 'error', // Reenabled for non-Node files only
105+
'node/no-unpublished-require': 'error', // Reenabled for non-Node files only
106+
},
107+
},
108+
{
109+
/// non-tests
110+
files: [...nodeFiles, ...browserFiles],
111+
rules: {
112+
'@typescript-eslint/no-unused-expressions': 'error', // Reenabled for non-tests only (Chai needs this disabled)
113+
},
114+
},
115+
{
116+
// TS files
117+
files: ['*.ts'],
118+
rules: {
119+
'@typescript-eslint/explicit-function-return-type': 'error', // We want to be strict with types
120+
'@typescript-eslint/no-unsafe-assignment': 'error', // Reenabled for TS files only
121+
'@typescript-eslint/no-unsafe-call': 'error', // Reenabled for TS files only
122+
'@typescript-eslint/no-unsafe-member-access': 'error', // Reenabled for TS files only
123+
'@typescript-eslint/no-unsafe-return': 'error', // Reenabled for TS files only
124+
},
125+
},
126+
],
58127
};

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
/node_modules/
1010

1111
# misc
12-
/.env*
13-
/.pnp*
1412
/.sass-cache
1513
/connect.lock
1614
/coverage/
@@ -23,3 +21,7 @@
2321
/.node_modules.ember-try/
2422
/bower.json.ember-try
2523
/package.json.ember-try
24+
25+
# IDE
26+
/.idea/
27+
/.history/

.lintstagedrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
module.exports = {
4+
// Run TSC on all the codebase.
5+
// Can't run TSC on individual files because we have two envs: Node and browser,
6+
// and TSC does not support providing a config and a path to a specific file at the same time.
7+
// Thus, two separate configs are used: one for Node, one for browser.
8+
// The function allows running the command globally, rather than once per each staged file.
9+
'{addon,addon-test-support,app,mirage,test-support,tests,types}/**/*.ts': () => 'yarn lint:ts -p tsconfig.json',
10+
'{*,.*,blueprints/*/*,config/**/*,lib/*/index,server/**/*}.{js,ts}': () => 'yarn lint:ts -p tsconfig-node.json',
11+
12+
// Run ESLint, typescript-eslint and Prettier on staged files only
13+
'**/*.{js,ts}': ['yarn lint:eslint --fix'],
14+
15+
// Template lint
16+
'**/*.hbs': ['yarn ember-template-lint'],
17+
};

.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
arrowParens: 'always', // It's convenient that you don't have to add them by hand when you need to add more args or a type
3+
singleQuote: true, // Enabled to align with EmberJS Prettier config
4+
printWidth: 100, // Per team's agreement
5+
trailingComma: 'es5', // Trailing commas makes editing easier, diffs cleaner. `es5` option aligns with EmberJS Prettier config
6+
};

.template-lintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'octane'
4+
extends: 'recommended'
55
};

0 commit comments

Comments
 (0)