Skip to content

Commit

Permalink
dev: updated linter, updated packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Jan 28, 2025
1 parent 364f579 commit f54d99a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ module.exports = {
},
},
],
plugins: ['prettier', 'eslint-plugin-react-compiler'],

plugins: ['prettier', 'eslint-plugin-react-compiler', 'internal'],
rules: {
'internal/enforce-spacing-values': 'error',
'react-compiler/react-compiler': 'error',
'prettier/prettier': [
'error',
Expand Down
53 changes: 53 additions & 0 deletions eslint/eslint-plugin-enforce-spacing-values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const allowedValues = [2, 4, 8, 12, 16, 24]

module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Enforce border, padding, and margin values to be 2, 4, 8, 12, or 16',
category: 'Stylistic Issues',
recommended: false,
},
schema: [], // no options
messages: {
invalidValue: `The value '{{value}}' for '{{property}}' is not allowed. Use ${allowedValues.toString()} instead.`,
},
},
create(context) {
const relevantProperties = [
'margin',
'marginTop',
'marginBottom',
'marginLeft',
'marginRight',
'marginHorizontal',
'marginVertical',
'padding',
'paddingTop',
'paddingBottom',
'paddingLeft',
'paddingRight',
'paddingHorizontal',
'paddingVertical',
'borderRadius',
]

return {
Property(node) {
if (relevantProperties.includes(node.key.name)) {
const value = node.value.value
if (typeof value === 'number' && !allowedValues.includes(value)) {
context.report({
node,
messageId: 'invalidValue',
data: {
value,
property: node.key.name,
},
})
}
}
},
}
},
}
8 changes: 8 additions & 0 deletions eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable object-shorthand */
// eslint-plugin-react-native-stylesheet/index.js

module.exports = {
rules: {
'enforce-spacing-values': require('./eslint-plugin-enforce-spacing-values'),
},
}
16 changes: 12 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"babel-plugin-inline-import": "^3.0.0",
"babel-plugin-react-compiler": "^19.0.0-beta-a7bf2bd-20241110",
"cui-fs": "^0.1.2",
"cui-llama.rn": "^1.4.1",
"cui-llama.rn": "^1.4.2",
"drizzle-orm": "^0.36.2",
"eas-cli": "^14.5.0",
"eslint-plugin-react-compiler": "^0.0.0-experimental-7c1344f-20241009",
Expand Down Expand Up @@ -87,6 +87,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-universe": "^12.0.0",
"eslint-plugin-internal": "file:./eslint",
"eslint-plugin-prettier": "^5.1.3",
"i18next-scanner": "^4.6.0",
"patch-package": "^8.0.0",
Expand Down

0 comments on commit f54d99a

Please sign in to comment.