Skip to content

Commit

Permalink
Linting (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfheij-sil authored Sep 5, 2023
2 parents f25bfec + b795402 commit 35168bf
Show file tree
Hide file tree
Showing 19 changed files with 20,313 additions and 4,812 deletions.
31 changes: 31 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Please keep this file in sync with .prettierignore and .stylelintignore

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# OSX
.DS_Store

.idea
npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

# Packager output
dist
release
temp-build

# generated files
package-lock.json
123 changes: 123 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
module.exports = {
extends: [
// https://github.com/electron-react-boilerplate/eslint-config-erb/blob/main/index.js
// airbnb rules are embedded in erb https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
'erb',
],

rules: {
// #region From paranext-core root .eslintrc.js
// Some rules are commented out since they have overrides in the
// 'Overrides from paranext-core extension .eslintrc.cjs' section

// #region ERB rules

'import/extensions': 'off',
// A temporary hack related to IDE not resolving correct package.json
'import/no-extraneous-dependencies': 'off',
'import/no-import-module-exports': 'off',
// 'import/no-unresolved': 'error',
'react/jsx-filename-extension': 'off',
'react/react-in-jsx-scope': 'off',

// #endregion

// #region Paranext rules

// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
'error',
'always',
{ exceptAfterSingleLine: true, exceptAfterOverload: true },
],
'@typescript-eslint/member-ordering': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': [
'error',
{
allow: ['arrowFunctions', 'functions', 'methods'],
},
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, allowNamedExports: true, typedefs: false, ignoreTypeReferences: true },
],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
{
assert: 'either',
},
],
// Should use our logger anytime you want logs that persist. Otherwise use console only in testing
'no-console': 'warn',
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'prettier/prettier': ['warn', { tabWidth: 2, trailingComma: 'all' }],
'react/jsx-indent-props': ['warn', 2],
'react/jsx-props-no-spreading': ['error', { custom: 'ignore' }],
'react/require-default-props': 'off',

// #endregion

// #endregion

// #region Overrides from paranext-core extension .eslintrc.cjs

'import/no-unresolved': ['error', { ignore: ['papi'] }],

// #endregion
},
globals: {
globalThis: 'readonly',
},
overrides: [
{
files: ['*.js'],
rules: {
strict: 'off',
},
},
{
// Don't require extensions to have a default export for "activate()"
files: ['*.ts'],
rules: {
'import/prefer-default-export': 'off',
},
},
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
createDefaultProgram: true,
},
plugins: ['@typescript-eslint'],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ release
dist-ssr
*.local

# formatting and linting
.eslintcache

# Editor directories and files
.idea
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Please keep this file in sync with .eslintignore and .stylelintignore

# Logs
logs
*.log
Expand All @@ -22,6 +24,8 @@ npm-debug.log.*

# Packager output
dist
release
temp-build

# generated files
package-lock.json
12 changes: 0 additions & 12 deletions .prettierrc

This file was deleted.

12 changes: 12 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
tabWidth: 2,
trailingComma: 'all',
endOfLine: 'lf',
singleQuote: true,
overrides: [
{
files: '*.json',
options: { parser: 'json' },
},
],
};
31 changes: 31 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Please keep this file in sync with .eslintignore and .prettierignore

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# OSX
.DS_Store

.idea
npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

# Packager output
dist
release
temp-build

# generated files
package-lock.json
17 changes: 17 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: ['stylelint-config-recommended', 'stylelint-config-sass-guidelines'],
overrides: [
{
files: ['**/*.scss'],
customSyntax: 'postcss-scss',
},
],
rules: {
'color-named': null,
'function-parentheses-space-inside': null,
'max-nesting-depth': 2,
'no-descending-specificity': null,
'selector-max-compound-selectors': 4,
'selector-max-id': 1,
},
};
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"editor.rulers": [100],
"editor.wordWrapColumn": 100,

"files.associations": {
".eslintignore": "ignore",
".prettierignore": "ignore",
".stylelintignore": "ignore"
},
"files.eol": "\n",
"cSpell.words": [
"asyncs",
Expand Down
Loading

0 comments on commit 35168bf

Please sign in to comment.