Skip to content

Commit

Permalink
build: lint configuration files (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 authored Nov 27, 2024
1 parent e79220c commit 36e5110
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
30 changes: 23 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ import eslintPluginCypress from 'eslint-plugin-cypress/flat'
import eslintPluginJasmine from 'eslint-plugin-jasmine'
import eslintPluginJsonFiles from 'eslint-plugin-json-files'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const gitignorePath = resolve(__dirname, '.gitignore')
import globals from 'globals'

const gitignorePath = resolve(
dirname(fileURLToPath(import.meta.url)),
'.gitignore',
)

const shouldEnableTypedRules = Boolean(process.env.TYPED_RULES)

const jsRules = [eslint.configs.recommended]

const useTypedRules = Boolean(process.env.TYPED_RULES)
export default tsEslint.config(
includeIgnoreFile(gitignorePath),
{
Expand All @@ -28,17 +34,27 @@ export default tsEslint.config(
'src/environments/environment.pull-request.ts',
],
},
// Configuration files. Right now ESLint and Karma.
{
files: ['*.mjs', '*.js'],
extends: [...jsRules],
languageOptions: {
globals: {
...globals.node,
},
},
},
{
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...jsRules,
// TODO: enable typed check recommended / stylistic
...tsEslint.configs.recommended,
...tsEslint.configs.stylistic,
],
languageOptions: {
parserOptions: {
...(useTypedRules
...(shouldEnableTypedRules
? {
projectService: true,
tsconfigRootDir: import.meta.dirname,
Expand Down Expand Up @@ -75,7 +91,7 @@ export default tsEslint.config(
selector: 'typeLike',
format: ['PascalCase'],
},
...(useTypedRules
...(shouldEnableTypedRules
? [
// https://github.com/typescript-eslint/typescript-eslint/blob/v8.16.0/packages/eslint-plugin/docs/rules/naming-convention.mdx#enforce-that-boolean-variables-are-prefixed-with-an-allowed-verb
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"eslint-plugin-json-files": "4.4.2",
"execa": "9.5.1",
"extensionless": "1.9.9",
"globals": "15.12.0",
"husky": "9.1.6",
"jasmine-core": "5.4.0",
"karma": "6.4.4",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36e5110

Please sign in to comment.