Skip to content

Commit

Permalink
feat: ignore camelcase rule for __webpack variables
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed May 20, 2023
1 parent 8d07cc2 commit 13785ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -118,6 +118,12 @@ module.exports = {
'import/extensions': ['warn', 'always', {
ignorePackages: true,
}],
// ignore camelcase for __webpack variables
camelcase: ['error', {
allow: ['^UNSAFE_', '^__webpack_'],
properties: 'never',
ignoreGlobals: true

Check warning on line 125 in index.js

View workflow job for this annotation

GitHub Actions / eslint

Missing trailing comma
}],
},
overrides: [
{
Expand Down
6 changes: 6 additions & 0 deletions tests/eslint-config.test.ts
Expand Up @@ -28,4 +28,10 @@ test('TSX is linted', async () => {
expect(results).toHaveIssue({ruleId: 'jsdoc/check-tag-names', line: 5})
expect(results).toHaveIssue({ruleId: '@typescript-eslint/no-unused-vars', line: 7})
expect(results).toHaveIssueCount(2)
})

test('ignore camelcase for webpack', async () => {
const results = await lintFile('fixtures/webpack-nonce.js')
expect(results).toHaveIssueCount(1)
expect(results).toHaveIssue({ruleId: 'no-undef', line: 2 })
})
2 changes: 2 additions & 0 deletions tests/fixtures/webpack-nonce.js
@@ -0,0 +1,2 @@
// ignore camelcase for __webpack_ variables
__webpack_nonce__ = 'foo_bar'

0 comments on commit 13785ea

Please sign in to comment.