@react-native/eslint-plugin-specs 0.0.1 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -12,10 +12,14 @@
12
12
  const ESLintTester = require('eslint').RuleTester;
13
13
 
14
14
  ESLintTester.setDefaultConfig({
15
- parser: require.resolve('babel-eslint'),
15
+ parser: require.resolve('@babel/eslint-parser'),
16
16
  parserOptions: {
17
+ requireConfigFile: false,
17
18
  ecmaVersion: 6,
18
19
  sourceType: 'module',
20
+ babelOptions: {
21
+ presets: [require.resolve('@babel/preset-flow')],
22
+ },
19
23
  },
20
24
  });
21
25
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/eslint-plugin-specs",
3
- "version": "0.0.1",
3
+ "version": "0.0.5",
4
4
  "description": "ESLint rules to validate NativeModule and Component Specs",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -8,12 +8,17 @@
8
8
  "url": "git@github.com:facebook/react-native.git",
9
9
  "directory": "packages/eslint-plugin-specs"
10
10
  },
11
+ "scripts": {
12
+ "prepack": "node prepack.js"
13
+ },
11
14
  "dependencies": {
12
15
  "@babel/core": "^7.14.0",
16
+ "@babel/eslint-parser": "^7.18.2",
13
17
  "@babel/plugin-transform-flow-strip-types": "^7.0.0",
18
+ "@babel/preset-flow": "^7.17.12",
14
19
  "flow-parser": "^0.121.0",
15
20
  "make-dir": "^2.1.0",
16
- "pirates":"^4.0.1",
21
+ "pirates": "^4.0.1",
17
22
  "react-native-codegen": "*",
18
23
  "source-map-support": "0.5.0"
19
24
  },
package/prepack.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ const fs = require('fs');
11
+
12
+ /**
13
+ * script to prepare package for publish.
14
+ *
15
+ * Due to differences to how we consume internal packages, update a flag
16
+ */
17
+
18
+ fs.readFile('./react-native-modules.js', 'utf8', function (readError, source) {
19
+ if (readError != null) {
20
+ return console.error(
21
+ 'Failed to read react-native-modules.js for publish',
22
+ readError,
23
+ );
24
+ }
25
+
26
+ const result = source.replace(
27
+ 'const PACKAGE_USAGE = false;',
28
+ 'const PACKAGE_USAGE = true;',
29
+ );
30
+
31
+ fs.writeFile(
32
+ './react-native-modules.js',
33
+ result,
34
+ 'utf8',
35
+ function (writeError) {
36
+ if (writeError != null) {
37
+ return console.error(
38
+ 'Failed to update react-native-modules.js for publish',
39
+ writeError,
40
+ );
41
+ }
42
+ },
43
+ );
44
+ });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -13,6 +13,8 @@
13
13
  const path = require('path');
14
14
  const withBabelRegister = require('./with-babel-register');
15
15
 
16
+ // We use the prepack hook before publishing package to set this value to true
17
+ const PACKAGE_USAGE = true;
16
18
  const ERRORS = {
17
19
  misnamedHasteModule(hasteModuleName) {
18
20
  return `Module ${hasteModuleName}: All files using TurboModuleRegistry must start with Native.`;
@@ -24,15 +26,28 @@ let RNParserUtils;
24
26
 
25
27
  function requireModuleParser() {
26
28
  if (RNModuleParser == null || RNParserUtils == null) {
27
- const config = {
28
- only: [/react-native-codegen\/src\//],
29
- plugins: [require('@babel/plugin-transform-flow-strip-types').default],
30
- };
31
-
32
- withBabelRegister(config, () => {
33
- RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
34
- RNParserUtils = require('react-native-codegen/src/parsers/flow/utils');
35
- });
29
+ // If using this externally, we leverage react-native-codegen as published form
30
+ if (!PACKAGE_USAGE) {
31
+ const config = {
32
+ only: [/react-native-codegen\/src\//],
33
+ plugins: [require('@babel/plugin-transform-flow-strip-types').default],
34
+ };
35
+
36
+ withBabelRegister(config, () => {
37
+ RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
38
+ RNParserUtils = require('react-native-codegen/src/parsers/flow/utils');
39
+ });
40
+ } else {
41
+ const config = {
42
+ only: [/react-native-codegen\/lib\//],
43
+ plugins: [require('@babel/plugin-transform-flow-strip-types').default],
44
+ };
45
+
46
+ withBabelRegister(config, () => {
47
+ RNModuleParser = require('react-native-codegen/lib/parsers/flow/modules');
48
+ RNParserUtils = require('react-native-codegen/lib/parsers/flow/utils');
49
+ });
50
+ }
36
51
  }
37
52
 
38
53
  return {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.